8

I just got started with an EC2 instance and got my mail sending limit removed, allowing me to send emails from my instance. But due to lack of experience, I have no clue on how to enable receiving emails sent to me on that server.

The instance has an elastic IP and I have a domain name with an A record pointing to that IP. I can't seem to find better documentation on what steps need to be taken so if someone sends an email to info@mysite.com it either actually receives it or simply forwards it to my personal email.

I know that it involves using postfix but can't find a guide to properly configure it after the installation.

Eborbob
  • 213
  • 3
  • 13
Kartik
  • 191
  • 1
  • 4

4 Answers4

12
  • A record that points to your server.
  • MX record that points to your A record.
  • Mail daemon listening on port 25 -- I tend towards Postfix.
  • Firewall rules allowing port 25 to accept connections. On EC2, you need to set this in your security groups
Jeff Ferland
  • 20,239
  • 2
  • 61
  • 85
4

I was facing similar problems. I have an MX record set up and the ports unblocked in the security policies, but a port scan still shows port 25 as blocked.

I came across this answer on the AWS forum. It seems that you have to request to specifically unblock your port 25 / 445. http://mxtoolbox.com/ should be useful to test your server.

Lord Loh.
  • 1,049
  • 3
  • 15
  • 24
3

You'll need an SMTP daemon such as postfix installed, and thus, the ports open from the AWS security group for starters.

Then, you can follow a configuration guide - have a look at the postfix basic configuration guide.

In a nutshell, you'll want to be 100% sure you're not operating as an open rely. Here's a very basic main.cf for simple username based delivery that I use:

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no
append_dot_mydomain = no

myhostname = mail.domain.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases

mydestination = hostname.domain.com, localhost.mydomain.com, localhost
relayhost =
mynetworks = 127.0.0.0/8
#mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all


smtpd_helo_restrictions =
    permit_mynetworks,
    #reject_non_fqdn_hostname,
    reject_invalid_hostname,
    permit
thinice
  • 4,676
  • 20
  • 38
-1

It's also worth noting that sending email directly from ec2 instances will likely result in them being marked as spam.

Use the SES service from amazon to get around this - but also note that there are known bugs in that system.. such as mac osx default mime type for jpeg images being blocked.

If you're able to have mail somewhere else, I would do that as it can become a pain to implement workarounds for stupid SES "features".