I have already re-read the docs on this as well as other posts here and this is still very unclear to me. I have been testing various things to understand the difference between
virtual_alias_maps and I don't see the use of these 2 separate settings in postfix. This is what I found so far (Note - I am using postfix in the same server as my web server as null client to send emails only):
1) /etc/aliases file:
When I add the above to the
alias_maps, I noticed that some services like fail2ban are able to pick this and it sends root emails to the alias email addresses mentioned. However, I also noticed that some other services (like
myorigin setting that is adding the @mydomain.com). To fix this I then added the
When the above is added, all services uses this virtual aliases email. I also noticed that once I add the above, even fail2ban begins to ignore my initial settings in
/etc/aliases/ file and starts to follow the email address given in virtual file.
Now this has confused me even more -
Why do we need
/etc/aliases/when having the email inside virtual aliases map seems to override it?
What is the purpose of having these 2 separate aliases mapping and when do we decide when to use what?
Why did fail2ban (which is configured to email to
root@localhost) first follow email address given in
alias_maps(/etc/aliases/) and later decides to ignore that once
Why doesn't all services read email aliases mentioned in /etc/aliases and they only work when the email aliases are added in virtual alias map?
I have spend several hours since yesterday and still unsure. Can someone help me clear my confusion?
This is the mail log when email is sent to root using
mail root command. The aliases email for root is mentioned in /etc/aliases/. But mail does not work until I move this root aliases email from
Log when root email alias is mentioned in
Nov 14 16:39:27 Debian postfix/pickup: 0F12643432: uid=0 from=<root> Nov 14 16:39:27 Debian postfix/cleanup: 0F12643432: message-id=<20141114110927.0F12643432@Debian.domainname.com> Nov 14 16:39:27 Debian postfix/qmgr: 0F12643432: from=<firstname.lastname@example.org>, size=517, nrcpt=1 (queue active) Nov 14 16:39:27 Debian postfix/error: 0F12643432: to=<email@example.com>, orig_to=<root>, relay=none, delay=0.04, delays=0.03/0/0/0.01, dsn=4.4.1, status=deferred (delivery temporarily suspended: connect to domainname.com[18.104.22.168]:25: Connection refused)
This is the log after the email aliases for root is moved from
/etc/postfix/virtual where the email delivery is successful after the change:
Nov 14 16:44:58 Debian postfix/pickup: ADD9A43436: uid=0 from=<root> Nov 14 16:44:58 Debian postfix/cleanup: ADD9A43436: message-id=<20141114111458.ADD9A43436@Debian.domainname.com> Nov 14 16:44:58 Debian postfix/qmgr: ADD9A43436: from=<firstname.lastname@example.org>, size=453, nrcpt=1 (queue active) Nov 14 16:45:00 Debian postfix/smtp: ADD9A43436: to=<email@example.com>, orig_to=<root>, relay=somesite.com[22.214.171.124]:25, delay=1.9, delays=0.03/0/0.97/0.88, dsn=2.0.0, status=sent (250 OK id=1XpEqC-0002ry-9s) Nov 14 16:45:00 Debian postfix/qmgr: ADD9A43436: removed