0

I have configured my Postfix server to use aliases. Incoming mail sent to contact@mydomain.com is redirected to myname@mydomain.com.

But it looks like my alias map is also rewriting the outgoing mail recipient, because when I send an email to contact@anotherdomain.com, I receive the following undelivered mail report:

<myname@anotherdomain.com> (expanded from <contact@anotherdomain.com>):
host mail.anotherdomain.com[x.x.x.x] said:
    550 5.1.1 <myname@anotherdomain.com>: 
    Recipient address rejected:
    User unknown in virtual mailbox table (in reply to RCPT TO command)

This is what my main.cf looks like (only part of it):

virtual_mailbox_domains = $mydomain
virtual_mailbox_maps = mysql:/etc/postfix/mysql-mailbox-maps.cf
virtual_alias_maps = mysql:/etc/postfix/mysql-alias-maps.cf
alias_maps =

Aliases are queried with:

SELECT CONCAT(destination, '@%d') FROM alias WHERE source = '%u';

And my master.cf (only part of it):

smtp inet n - n - - smtpd

submission inet n - n - - smtpd
    -o syslog_name=postfix/submission
    -o smtpd_client_restrictions=permit_sasl_authenticated,reject

How do I prevent Postfix from rewriting the outgoing mail recipient?

Toun
  • 101
  • 2
  • It looks like you're using aliases with system users, you might want to use aliases with virtual users, also, why are you using `virtual_alias_maps` on `submission`, instead of `local` ? That said, are your aliases `contact` `myname` instead of `contact@tsomedomain` `myname` ? – NickW May 02 '17 at 13:32
  • Currently I have only one alias, `contact` to `myname`. I'm using a MySQL DB to store virtual users and aliases, that's what `virtual_mailbox_maps` and `virtual_alias_maps` are for right? I don't think I'm using system users at all. Also I used `virtual_alias_maps` with an empty value on `submission` to override the `main.cf` default, is that not how it works? – Toun May 02 '17 at 14:50
  • Alright, if you want to map only `contact@mydomain` to `myname@mydomain` you need to have an entry in your alias DB that maps `contact@mydomain` `myname` that way if you use `contact@someotherdomain` it won't match. Postfix will use the entire name for the match. – NickW May 02 '17 at 14:54
  • Ok thanks, I thought about it and that's probably what I will be doing. But just out of curiosity, is there no way to simply tell Postfix to skip the virtual alias map checking for outgoing mail? It would also avoid one SQL request which can only be good for performance. – Toun May 02 '17 at 15:20
  • Yeah, you'd normally want your alias lookup on `local` not `submission` as `submission` submits mail to both local delivery and smtp (or any other transport methods that can be used). That or just don't include it in master.cf? – NickW May 02 '17 at 15:22

0 Answers0