8

I've recently signed up to SMTP2GO (smtpcorp). I've setup postfix on one of EC2 servers and have pointed it to my smtp2go account:

relayhost = [smtpcorp.com]:2525

Now all my mail is being routed through SMTP2GO, but the issue is, that the 1000+ emails that are generated by cron job ect are being sent to SMTP2GO using the email address:

root@ec2-46-51-151-256.eu-west-1.compute.amazonaws.com

My question is, what would be the best way to stop all these "local" emails being routed to SMTP2GO?

Thanks

Martin

My main.cf:

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

append_dot_mydomain = no


readme_directory = no

smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache



myhostname = ec2-46-51-151-256.eu-west-1.compute.amazonaws.com

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname

mydestination = ec2-46-51-151-256.eu-west-1.compute.amazonaws.com, localhost.eu-west-1.compute.internal, localhost

relayhost = [smtpcorp.com]:2525
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = static:account:password
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = may
header_size_limit = 4096000
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = ipv4
user149631
  • 83
  • 1
  • 1
  • 4

2 Answers2

8

Postfix relayhost doesn't send local mail to the relayhost normally:

From postfix.org:

relayhost (default: empty)

The next-hop destination of non-local mail; overrides non-local domains in recipient addresses. This information is overruled with relay_transport, sender_dependent_default_transport_maps, default_transport, sender_dependent_relayhost_maps and with the transport(5) table.

So if it is happenning, it is because your local mail is not identified as local. You need to include your local domain in mydestination = config line. I see you have the ec2-....amazonaws.com there but probably you have defined a local domain different than this one for your LAN. If you don't have defined a local domain, I think (needs testing) if you only add 127.0.0.1 localhost.localdomain localhost in your etc/hosts file and add localhost.localdomain to mydestination= it should be sufficient.

laurent
  • 2,035
  • 16
  • 13
  • 1
    I think this did it! All i did was take the offending domain and append it to the domains in "mydestination =" , now i'm not getting any more of the 'internal' emails, thanks a lot! – user149631 Dec 14 '12 at 15:30
0

It is sending the output of cron etc. to the root account on the server, as per the default settings in Ubuntu.

To have all mail sent to this address diverted somewhere else, edit your aliases file to include the following line:

enter code hereroot: "me@example.com"

Then run newaliases. This works with postfix ok.

Alternatively you could set up forwarding of all mail to root by adding/editing ~root/.forward and adding a line with the preferred email address.

See https://unix.stackexchange.com/questions/26666/can-i-change-roots-email-address-or-forward-all-mail-to-an-external-address

dunxd
  • 9,482
  • 21
  • 80
  • 117
  • Thanks dunxd, do you know if there is a way so that the emails don't leave the server? Currently 90% of outbound mail is from cronjobs. Preferrably it would be nice to store these emails on the filesystem, and not have the routed to SMTP2GO, Thanks! Martin – user149631 Dec 14 '12 at 12:19
  • See what laurent said - I misunderstood your question – dunxd Dec 14 '12 at 15:30