Class 3: Configuring Email
Last Updated by Code Sport. Filed under classes, courses, emailInstalling and Configuring Mailutils and Postfix To Send Email Postfix and mailutils…
Postfix and mailutils allow your LAMP server to send email. Postfix is a mail server and Mailutils installs, well… a bunch of mail utilities including the popular UNIX mail reader called mail.
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 email@example.com with hello world, my email works! as the subject.
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: www-data@mail.example.com Received: from mail.example.com ([50.57.129.231])
Type $ sudo nano /etc/mailname
to edit the Return-Path
. Domain mismatches between the “Return-Path” and the “from” address may set-off spam filters.
Type $ sudo nano /etc/postfix/main.cf
to edit the From
header. The value of myhostname
is outputted as the From
header
<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