The Slicehost-Cogent-Outage, or How to setup a relay with Postfix

Wednesday, May 5. 2010

Our problem is that an application hosted on Slicehost uses an external mailserver, which is located in Europe. Since neither Slicehost/Rackspace or Cogent seem to be able to fix the situation after almost two days, here's a quick workaround.

The idea is that our relay will collect emails and send them whenever the connection permits.

Postfix install

This is a pretty simple:

sudo aptitude install postfix


Edit /etc/postfix/ (this is my entire

smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl/passwd
smtp_sasl_security_options =
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
append_dot_mydomain = no
readme_directory = no
myhostname = **MY-SLICE-HOSTNAME**
mynetworks =, **MY-SLICE-IP**
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination =
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = loopback-only

Obviously you need to replace the **ENTRIES** in caps entries (a total of three).


Create the file:

sudo touch /etc/postfix/sasl/passwd
sudo chmod 600 /etc/postfix/sasl/passwd

Enter something like the following in it (vi /etc/postfix/sasl/passwd): username:password [email protected]:password

Replace mail/mail2 with your actual SMTP. The SMTP will have to allow plain-text login for this to work.

Run the following to finish up:

sudo postmap /etc/postfix/sasl/passwd


sudo /etc/init.d/postfix check
sudo /etc/init.d/postfix reload

Then, configure your application to not use smtp-auth and your SMPT runs on if it runs on the same server.

Please note in the above, I configured postfix to only listen on the loopback.


This is an excerpt from an email:

    Received: from [slice.ip] (
    by with esmtpa (Exim 4.69)
    (envelope-from )
    id 1O9gAL-0005xQ-ES; Wed, 05 May 2010 17:05:37 +0200
    Received: from [slice.ip] (localhost [])
    by (Postfix) with ESMTP id DE2DB11428C;
    Wed,  5 May 2010 15:05:44 +0000 (UTC)

And that's all, kids!