The Slicehost-Cogent-Outage, or How to setup a relay with Postfix
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.
This is a pretty simple:
sudo aptitude install postfix
/etc/postfix/main.cf (this is my entire
relayhost = **MY-EXTERNAL-MAILSERVER (SMTP)** 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 = 127.0.0.0/8, **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 (
mail.example.org username:password mail2.example.org [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
127.0.0.1:25 if it runs on the same server.
Please note in the above main.cf, I configured postfix to only listen on the loopback.
This is an excerpt from an email:
Received: from [slice.ip] (helo=slice.host) by mailserver.in.europe with esmtpa (Exim 4.69) (envelope-from
) id 1O9gAL-0005xQ-ES; Wed, 05 May 2010 17:05:37 +0200 Received: from [slice.ip] (localhost [127.0.0.1]) by slice.host (Postfix) with ESMTP id DE2DB11428C; Wed, 5 May 2010 15:05:44 +0000 (UTC)
And that's all, kids!