I have a website on a server with a postfix mail server to send the site's emails. Let's say the domain is example.com.

The site can send mails to mailboxes of his own domain (like contact@example.com), which is hosted on another server and to any other domains.

As I don't want any local delivery, even for example.com, the mydestination parameter is empty.

This worked great, but I can't redirect mails to local users. For example, if mdadm send a mail to root, the mail will be sent to root@example.com directly, without going throw /etc/aliases.

How can I deliver localy mails to local users, and keep sending mails to mailboxes @example.com?


Use localhost for mydestination and myorigin

mydestination = localhost
myorigin = localhost

With this setup, when mdadm send email to root, it will transformed to root@localhost. With mydestination = localhost, postfix will consult /etc/aliases to do aliasing.

If you aren't comfortable with root@localhost in return-path, then you can use smtp_generic_maps to repair it

smtp_generic_maps = hash:/etc/postfix/rewrite

localhost example.com
  • Your solution works, but the mail headers now contains localhost instead of example.com : I get Return-Path: <colin@localhost> instead of Return-Path: <colin@example.com> for mail sent by the user colin. – Congelli501 May 5 '15 at 15:01
  • See updated answer – masegaloeh May 5 '15 at 22:13

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.