Installing and Configuring Mailutils and Postfix To Send Email

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, 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., you want to use for your server.

To test your install type:

$ echo "hello world, my email works!" | sendmail -v

The above command will send an email to 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.

Received: by with SMTP id s8csp130500oex;
        Sun, 25 Nov 2012 07:29:26 -0800 (PST)
Received: by with SMTP id uj15mr11096932igb.52.1353857365465;
        Sun, 25 Nov 2012 07:29:25 -0800 (PST)
Received: from ([])

1. Return-Path Header Setup for Email

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.

2. From Header Setup

Type $ sudo nano /etc/postfix/ to edit the From header. The value of myhostname is outputted as the From header

<other configurations>
myhostname =
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination =,, , localhost
relayhost =
mynetworks = [::ffff:]/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