Translation(s): English - Italiano

Postfix is a secure Mail Transfer Agent


Installing and Configuring Postfix on Debian

apt-get install postfix

cat /var/log/mail.log

postconf -e "myorigin ="

postconf -e ""

postconf -e "relay_domains =,,"

postfix reload

telnet localhost 25

Connected to localhost.localdomain.
Escape character is '^]'.
220 ESMTP Postfix (Debian/GNU)

mail from:<>
rcpt to:<>
Subject: Hey my first email
This is my first email on debian postfix after installing configuring it.
It was easy.



qshape deferred
postsuper -r ALL   (requeue all emails)

anti-spam: smtp restrictions

smtpd_recipient_restrictions = reject_invalid_hostname,

smtpd_helo_restrictions = reject_invalid_helo_hostname,

anti-spam: Using RBL Lists

Insert this in your /etc/postfix/

smtpd_client_restrictions = reject_rbl_client

See what rbl is about:

and avoid such blacklists

Debian Anti-Spam Anti-Virus Gateway Email Server

Postfix and sbcglobal/yahoo/att

apt-get install libsasl2-modules

postconf -e "relayhost = []:587"
postconf -e "smtp_sasl_auth_enable = yes"
postconf -e "smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd"
postconf -e "smtp_sasl_security_options = noanonymous"


chmod 600 /etc/postfix/sasl_passwd

postmap /etc/postfix/sasl_passwd

postfix reload

Forward Emails

postconf -e "alias_maps = hash:/etc/aliases"

root: lucas


lucas: lucas


/etc/init.d/postfix reload

Virtual Emails

postconf -e "virtual_alias_maps = hash:/etc/postfix/virtual"

vi /etc/postfix/virtual

someemail lucas

postmap /etc/postfix/virtual

/etc/init.d/postfix reload


postconf -e "home_mailbox = Maildir/"
postconf -e "mailbox_command ="


vi /etc/Muttrc

set folder="~/Maildir"
set mask="!^\\.[^.]"
set mbox="~/Maildir"
set record="+.Sent"
set postponed="+.Drafts"
set spoolfile="~/Maildir"

Postfix and mailing lists

Mailman with Postfix

(!) The instructions below are WRONG! You should not and alias at the same time. Please read /etc/mailman/ instead.

apt-get install mailman

newlist mailman

/etc/init.d/mailman start

relay_domains =,

alias_maps = hash:/etc/aliases,hash:/var/lib/mailman/data/aliases

postconf -e "transport_maps = hash:/etc/postfix/transport"
postconf -e "mailman_destination_recipient_limit = 1"

mailman unix  -       n       n       -       -       pipe
   flags=FR user=list
   argv=/var/lib/mailman/bin/ ${nexthop} ${user}    mailman:

postmap /etc/postfix/transport

MTA = 'Postfix'

/etc/init.d/postfix reload
/etc/init.d/mailman restart

newlist list_name

Alias /pipermail/ /var/lib/mailman/archives/public/
Alias /images/mailman/ /usr/share/images/mailman/

Then you need to reload apache:

/etc/init.d/apache2 reload

Mailman Troubleshooting

Connection refused

Assuming your postfix is running and listening on localhost, another possible problem is that postfix is not configured to run in IPv6 mode, but your /etc/hosts file specifies ::1 as localhost. In that case mailman tries to send mails to ::1 which has no postfix listening, thus resulting in a (111, 'connection refused') error.

Advanced options

SPF and multiple external ip addresses


I have some systems that are networked on an internal private ip address subnet ( For a few reasons I email reports and such to <user>@mail.internal where user is an address that is not valid for receiving mail via the external interfaces. These systems also share a public ip address subnet so they could email each other that way, but I'd prefer they didn't for local addresses. I have published SPF records for the public mail servers because all of our mail routes through those servers so if others care to check they can ignore email claiming to be from us but being delivered from other servers as per our SPF record.

Recently I have expanded the ip addresses these systems are using externally to support multiple instances of port-based services like https (adding :oddport doesn't impress the customers.) I could have expanded or added more liberal SPF record values, or added more forward and reverse DNS records but I wanted to stick with less ip addresses.

So to recap my system has:

By using the settings in /etc/postfix/, /etc/postfix/ and /etc/postfix/transport as outlined above I was able to get my outgoing smtp traffic to use my SPF published ip address once again.

Make SPF and multiple external ip addresses

If you are trying to implement SPF records while binding to one external ip address and still working with dual-homed multiple ip aliased systems, or have any other reason to support multi-homed systems with multiple ip addresses but want to limit postfix to use only two of them try this.

 smtp      unix  -       -       -       -       -       smtp
        -o smtp_bind_address=<spf published ip address>
 smtpinternal      unix  -       -       -       -       -       smtp
        -o smtp_bind_address=<internal ip address>

 transport_maps = hash:/etc/postfix/transport

 .internal smtpinternal:

Just postmap /etc/postfix/transport, invoke-rc.d postfix stop and invoke-rc.d postfix start and you should be in business. Email to <user>@<system>.internal will be delivered via the internal interface/ip address all other email will be delivered via default methods which means internet mail will go out the the spf published ip address.


Postfix and Sasl

External links

Please see Postfix/Tutorials