Some days ago I got a very cheap VPS from VULTR with 125GB of SATA storage for only $5,- a month. A small VPS which is fast enough for my websites backups. While all my other VPS servers are installed with Serverpilot, this server was installed with only with Ubuntu 14.04. Because my backups are created by native Linux function like rsync (executed by some CRON jobs), there is no other software required. There is one bottom-line, this configuration doesn’t include any mail function. I used the following steps to configure Postfix & Mailgun for my little server.
Mailgun transactional SMTP mail service
I use Mailgun for a couple of websites, because they offer a powerful interface and the first 10.000 mails are free :) If you follow these steps you need a Mailgun account. Create one and add also a (sub)domain you would like to use as the sender domain. Next verify your domain ownership and create some credentials for your SMTP account.
Install Postfix on your VPS with Ubuntu 14.04
Use the following command to create the necessary email tools, including Postfix:
sudo apt-get install mailutils
During the installation process, Postfix will ask you several settings, use the default setting Internet Site.
Now open the config file “/etc/postfix/main.cf” and change/add these settings:
inet_interfaces = loopback-only relayhost = [smtp.mailgun.org]:587 smtp_sasl_auth_enable = yes smtp_sasl_password_maps = static:[email protected]:password smtp_sasl_security_options = noanonymous
Replace [email protected]:password with the login credential you have created before. Save the config file and restart Postfix.
sudo service postfix restart
To check that anything is working you can send this test mail:
echo "This is my email test message" | mail -s "My subject line" [email protected]
Forward your root email messages
The last step is to set a mail forwarder for all message of the root account. Edit the file named “/etc/aliases” and add your email address:
# See man 5 aliases for format postmaster: root root: [email protected]
The last step is optional and depends on your VPS server setup. If you install more tools on your server, you might get (much) more message than you like.