Since my domain name is tied to a linux droplet hosted on digital ocean, running a mail server on the droplet is a logical choice. Installing and configuring server applications can be time consuming, and I was worried this would be a large chunk of work. But actually, the mail server was configured and up and running in a flash. I was pleasantly surprised by the software. In this article I will examine the steps that were necessary to get the mail server up and running.
sudo vi /etc/hostnameThe contents of this file should look something like this:
yourdomain.comMail servers typically use the hostname to identify the server they are running on.
First we need to install the software:
sudo apt-get install postfix sudo dpkg-reconfigure postfixNext we need to edit the main configuration file:
sudo nano /etc/postfix/main.cfI had to fix the myhostname variable to point to my domain:
myhostname = yourdomain.comNext I had to enable the virtual alias map:
virtual_alias_maps = hash:/etc/postfix/virtualThe virtual alias map is used to redirect email messages. This is a really powerful tool and I was surprised at how easy to use it is. Simply create / edit the text file for virtual emails:
sudo vi /etc/postfix/virtualNormally linux creates an email address per user of the format [user]@[domain]. The email adresses mentioned here are virtual addresses. In other words, the user doesn't need to exist. Like I said in the introduction I wanted to forward incoming emails to my private email address.
email@example.com firstname.lastname@example.orgEntering the above line into /etc/postfix/virtual would forward incoming emails for the virtual user "someone" to Ryans privates. It is also possible to reroute messages for a virtual user to an actual linux user, like so:
email@example.com rootTo load the changed configuration and (re)start the server:
sudo postmap /etc/postfix/virtual sudo service postfix restartAnd you can test the configuration by sending an email to firstname.lastname@example.org.
Personally, I am sending mails from the command line through SSH.
There is a whole bunch of command line email clients one can use:
Personally I chose mutt, because I found it to be the simplest to use. Editing the email body is most comfortable in a text editor:
vi message.txtSending the message:
mutt -s "subject line" email@example.com < message.txtAttaching a file somewhere on the filesystem can be done with the -a flag:
mutt -s "subject of email with attachment" firstname.lastname@example.org -a /somewhere/file.txt < message.txtI find adding attachments to a file this way particularly efficient. It is far less complicated than in a webmail client. Of course there are command line flags for adding CC's Bcc's etc. Check the manual:
man muttUsing the command line to send emails works really nice for me. I can easily send test mails to myself for review, before I send them to a possible client. Simply change the destination email on the command line and suddenly it is sent to the real destination. Main Page