Installing and Configuring Mailutils and Postfix To Send Email
Enabling your server to send email is useful for applications (e.g., WordPress) that send confirmation emails to users. But, note that we will not be setting-up an outgoing mail server. Instead, we’ll use a third party webmail provider. Some of options include gandi.net, Google for Business, Outlook 360, and Zoho Mail.
Ok, let’s get started! To install postfix and mailutils type:
$ sudo apt-get install postfix mailutils
During the install you will be prompted with a few questions. Setup your server as an
Internet Site and enter your FQDN as the primary domain name (e.g., my_cool_site.com) you want to use for your server.
To test your install type:
$ echo "hello world, my email works!" | sendmail -v email@example.com
The above command will send an email to firstname.lastname@example.org with hello world, my email works! as the subject.
Changing And Customizing Postfix Email Headers
Below is the email header of the test message sent above. The “Return-Path” and “Received: from” header, which we have highlighted, may be further customized to your liking.
Delivered-To: email@example.com Received: by 10.60.80.168 with SMTP id s8csp130500oex; Sun, 25 Nov 2012 07:29:26 -0800 (PST) Received: by 10.50.150.175 with SMTP id uj15mr11096932igb.52.1353857365465; Sun, 25 Nov 2012 07:29:25 -0800 (PST) Return-Path: firstname.lastname@example.org Received: from mail.example.com ([220.127.116.11])
1. Return-Path Header Setup for Email
$ sudo nano /etc/mailname to edit the
Return-Path. Domain mismatches between the “Return-Path” and the “from” address may set-off spam filters.
2. From Header Setup
$ sudo nano /etc/postfix/main.cf to edit the
From header. The value of
myhostname is outputted as the
<other main.cf configurations> myhostname = mail.example.com alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases myorigin = /etc/mailname mydestination = mail.example.com, localhost.example.com, , localhost relayhost = mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = all
After you have made your updates, restart postfix so your changes may take effect:
$ sudo service postfix restart