Light on Dark
RSintheCloud.com -:- User Guides

email setup for PostFix

We have installed Postfix as an internet server, and this will work for outgoing mail, except for a couple of problems.  The first of these is that the receiving system will probably reject the message as coming from an invalid hostname, and the second is that you will not be able to send mail to many users as it will be marked as spam. You also want to set up your Elastic IP and your DNS record before you do this, as it will need redoing if the IP or hostname changes

The following is applicable to most mail servers, not just Postfix - we do not look at the Postfix settings here.

The easiest way to set up and test email is via WebMin.  If you have not installed it, do so now - click here for details

First, see if mail is working – let’s send a test.

Log in to WebMin - you will need to use the user and password you have set up for this, as root and Ubuntu do not have a password.

Go to Servers, Read User Mail and select the user you are logged in as.
Read User Mail

Go into their mailbox and 'compose' a new message
User Mailbox
Compose
Fill in to, subject and message
Click send

Check the result in System - System Logs - click on 'view' for the mail log
System Logs

This is a bit later - the most recent messages are at the bottom.
Logfile

Here you can see the lines highlit in yellow, saying invalid domain:
host mx00.1and1.co.uk[212.227.15.169] said: 421 invalid sender domain 'ip-10-56-74-103.eu-west-1.compute.internal' (misconfigured DNS?) (in reply to RCPT TO command)

And at the bottom a later (successful) message

To fix the domain we need to set the hostname of the computer to match the DNS record we set up.

Network Config

Hostname

Set the Hostname and set the search domain to 'None'
DNS
Apply

Go back to the mail log and look at the latest message - it should have a status of 250 and be 'accepted':
Nov 11 15:31:50 ip-10-56-74-103 postfix/smtp[15314]: CF1A0234DF: to=<john@xxxo.uk>, relay= ..... 0.0, status=sent (250 Message 0MXZUw-1RSkPQ0c3a-00WUMj accepted by mxeu3.kundenserver.de)

Aliases

Now we need to set up aliases – root and www-data can both receive messages and will fill up the mailbox and eventually the disk if nothing is done. Aliases allow all the mail to be forwarded to a 'real' mailbox to be read.

Postfix


Alias

Change Postmaster and add root and www-data (yes, the picture is wrong!). Point them at a real user, then forward this to a real mailbox. You could forward each individually, if you have different postmaster and webmaster accounts.

New Aliases

Normally that is all you need to do, but we are working in the AWS Cloud, and AWS are a bit silly at times. Within a few minutes of testing this mail server you will get an e-mail off AWS:
e-mail

For those with small monitors, here's what it says:

Dear EC2 Customer,
You recently reached a limit on the volume of email you were able to send out of SMTP port 25 on your instance:
Instance ID: i-de488397

In order to maintain the quality of EC2 addresses for sending email, we enforce default limits on the amount of email that can be sent from EC2 accounts. If you wish to send larger amounts of email from EC2, you can apply to have these limits removed from your account by filling out our online request form.

This sounds quite reasonable – stop people sending hundreds of messages – except the default limit is about 5.  By the time you have tested it and sorted out the rest of the mail system, you will get this warning.

The ‘online request form’ is at https://aws-portal.amazon.com/gp/aws/html-forms-controller/contactus/ec2-email-limit-rdns-request  Opens in new window
and looks like:


Request part 1
Request part 2

Fill this in, all three sections if you have EIP and DNS set up, as you will be blacklisted otherwise, and submit.
Request received

 

And that is just about it. The only thing left is to go through any mailboxes which have mail in them and check what it says - it could be showing a problem, for example the following is from the root mailbox:

/etc/cron.daily/popularity-contest: .: 18: Can't open /etc/popularity-contest.conf run-parts: /etc/cron.daily/popularity-contest exited with return code 127

I will look at this tomorrow, for tonight it will be a check that the 'root' mail forwarding is working.

And next day, here is the proof that what we have done is working:

email

Now we just need to fix the popularity contest!

Update: Here's the e-mail you will get a few days later, confirming AWS have unblocked your account. This takes a few days and the DNS blacklists can take another week, so plan ahead if you want to send lot's of mail.
Confirmation e-mail

 




















just making sure we have a vertical scroll bar, otherwise it jitters sideways.