Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm using Ubuntu 12.04 with postfix configured as satellite system that relays outgoing mail to Gmail. For sake of example, my registered domain is example.com I want root cronjobs' error output to be mailed to my real david@example.com inbox. I have this relay working correctly.

But these root cronjobs are set by default to email to root@example.com which isn't a real email address. I have in my /etc/aliases:

root: david@example.com

example.com isn't listed in postfix's main.cf's mydestination so postfix doesn't think this mail is local. It bypasses processing via /etc/aliases and tries to send to root@example.com.

A workaround is adding MAILTO=david at the top of each cron file. But there are many. Another workaround is to setup root@example.com as a real inbox that forwards to david@example.com. Is there a better way? I.e. is there a way to relay emails that have local domains but still process their addressee with /etc/aliases?

share|improve this question

3 Answers 3

I guess you could use a virtual.

If example.com is your domain on postfix

on /etc/postfix/main.cf

virtual_alias_maps = hash:/etc/postfix/virtual

on /etc/postfix/virtual

root@example.com    dave

after edit

postmap hash:/etc/postfix/virtual

Should be working.

If i understood right your question, know mails to root@example.com wil go to local user dave.

share|improve this answer
    
This works for Centos 6 :) Thx –  MariuszS Nov 25 '13 at 14:37

if david is also a local account, then you could have the alias line be local-only, and then set up the david account to do the forwarding. /etc/aliases would be:

root: david

You could then use other postfix rules or a .forward file on the david account to get the mail to gmail.

share|improve this answer
1  
This is not working with relaying... –  MariuszS Nov 25 '13 at 14:38

Another solution is to use the recipient_canonical_maps configuration parameter of postfix. Compared to the virtual_alias_maps, the advantage is that myorigin neither needs to be in mydestination nor in virtual_mailbox_maps (which virtual_alias_domains defaults to). Thus, this postfix instance does not become the final destination for myorigin.

Add this to your main.cf:

recipient_canonical_maps = hash:/etc/postfix/recipient_canonical

Then create a file named /etc/postfix/recipient_canonical and enter something like this:

root@example.com david@example.com

Finally hash it.

# postmap /etc/postfix/recipient_canonical
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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