Mail Server
One day, I'll be able to write this up for DigitalOcean, and get some credit for my account: Write For DigitalOcean Share Your Technical Expertise!. But that's gong to take too long!
Why You May Not Want To Run Your Own Mail Server
All I want (right now) is to be able to send emails (from applications), and to send/receive on my own address using mutt
. Nothing that clever, postfix should be sufficient!
Prerequisite(s)
DNS
Having already configured an email server previously (see some extra notes below), I'd already setup DNS records, similar to in this guide:
- See sections “Setting up DNS” & “Verify DNS”: How To Set Up a Postfix E-Mail Server with Dovecot
- Note for TXT records:
- TXT records are a type of Domain Name System (DNS) record that contains text information for sources outside of your domain. You add these records to your domain settings. You can use TXT records for various purposes. Google uses them to verify domain ownership and to ensure email security.
Installation
Start off following instructions from the DigitalOcean Community Documentation How To Install and Configure Postfix on Ubuntu 20.04.
Note, postfix was already installed, so I needed to run:
sudo dpkg-reconfigure postfix
I followed the instructions up to the point of installing s-nail
, I prefer mutt
.
sudo apt-get install mutt
mutt
worked right away, sending an email to my personal email account, and receiving a reply from it.
Testing & Checking
Sent a test email to: Test sender TLS.
<html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>SUCCESSFUL</title> </head> <body> <p>SUCCESSFUL <a href="https://www.checktls.com/TestSender">//email/test <b>From:</b></a></p> <p>Your email was sent securely using TLS.</p> </body> </html>
Useful Tricks
Migrate Mailbox
# Change to home directory cd ~ # Copy mailbox data from backup sudo cp -r /mnt/volume_lon1_01/disk_backup/home/david/Maildir . # Fix file and directory ownership sudo chown -R david:david Maildir
bounce (forward) email
In mutt
to bounce (forward) an email to another address (say a HTML email forward to a regular mailbox), press b
when the email is selected and then put the address into the application and hit enter.
Requirements for Gmail to receive emails
MX Records
Google Domain TXT record
PTR Records
Mail servers must meet a number of requirements to prevent their messages from being blocked, e.g. have a PTR record. The use of authentication methods such as SPF, DKIM or DMARC minimize the chance that messages are marked as spam.
Mixed Links
Documentation
- DigitalOcean Community Documentation (e-mail) 20.04:
- DigitalOcean Community Documentation (e-mail) Original:
Various links used in debugging under older installation
- Suppresss “~/Mail does not exist” in mutt. Just create the dir and have done with it.
- How do I change the hostname without a restart? -
sudo hostname roman-halliday.com
Email server testing site: