I've configured postfix to relay gmail (google apps) but the emails are sending as root@example.com instead of admin@example.com as (I believe) I've configured. I think the config is ok because I'm not getting any error. The issue is that it tries to send as root which doesn't exist! How can I get the emails to send as admin@example.com as I specified in my sasl_password file and db?

For all config/logs, I've removed my domain and replaced with example.com.


Oct  1 13:40:57 mon1 postfix/qmgr[5449]: C01AD22880: from=<root@example.com>, size=450, nrcpt=1 (queue active)
Oct  1 13:40:57 mon1 postfix/local[5456]: C01AD22880: to=<admin@domain>, relay=local, delay=0.05, delays=0.03/0.01/0/0.01, dsn=2.0.0, status=sent (delivered to mailbox)


[smtp.gmail.com]:587 admin@example.com:MYPASSWORD

/etc/aliases (no tutorials suggested this, just one of the things I've tried)

root:       admin@example.com

additions to main.cf

relayhost = [smtp.gmail.com]:587
# enable SASL authentication
smtp_sasl_auth_enable = yes
# disallow methods that allow anonymous authentication. 
smtp_sasl_security_options = noanonymous
# where to find sasl_passwd
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
# Enable STARTTLS encryption 
smtp_use_tls = yes
# where to find CA certificates
smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.trust.crt
  • you can use sender_canonical_maps for masquerade the outgoing mails – c4f4t0r Oct 1 '14 at 14:37
  • Also, note that changes to the /etc/aliases files (at least for postfix, not sure about sendmail) require: /bin/newaliases ; service postfix restart #(or whatever you use to restart postfix on your distro). That aliases change ensures emails to root on your system get sent to admin@mydomain instead. Then, @c4f4t0r's answer ensures that the from message is also set to something valid, since some servers (e.g. Amazon SES) will reject the default root@localdomain. – JJC Jan 19 '15 at 16:54

you can use sender_canonical_maps for masquerade the outgoing mail, in you main.cf

sender_canonical_maps = hash:/etc/postfix/sender_canonical

echo "root admin@mydomain" >> /etc/postfix/sender_canonical
postmap /etc/postfix/sender_canonical

after that, reload your postfix service

  • Thanks very much, that's definitely worked as far as ensuring the sender is correct, unfortunately the mails aren't coming through though! – James Oct 1 '14 at 14:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.