So I need to create an alias on my postfix server that will redirect all mail to multiple email addresses.

I have postfix + postfixadmin with dovecot up and configured and everything seem to be working just fine and server is able to receive email and send email, so does creating new accounts, but not aliases.

When attempting to send email to newly created alias (created via postfixadmin), in /var/log/mail.log I see following

Mar 11 14:24:53 somedomain postfix/pipe[28581]: B1FEDBC0899: to=<testing@somedomain.com>, relay=dovecot, delay=0.68, delays=0.63/0/0/0.05, dsn=5.1.1, status=bounced (user unknown)
Mar 11 14:24:53 somedomain postfix/cleanup[26467]: 3B549BC0BE4: message-id=<20140311102453.3B549BC0BE4@somedomain.com>
Mar 11 14:24:53 somedomain postfix/bounce[28583]: B1FEDBC0899: sender non-delivery notification: 3B549BC0BE4

And email is bounced back with pretty much same error.

Problem is that alias exists and I can see it MySQL database and in postfixadmin interface.

root@someserver:~# postconf | grep alias
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
allow_mail_to_commands = alias, forward
allow_mail_to_files = alias, forward
expand_owner_alias = no
local_recipient_maps = proxy:unix:passwd.byname $alias_maps
newaliases_path = /usr/bin/newaliases
proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $sender_bcc_maps $recipient_bcc_maps $smtp_generic_maps $lmtp_generic_maps
unknown_virtual_alias_reject_code = 550
virtual_alias_domains = $virtual_alias_maps
virtual_alias_expansion_limit = 1000
virtual_alias_maps = proxy:mysql:/etc/postfix/mysql_virtual_alias_maps.cf, proxy:mysql:/etc/postfix/mysql_virtual_alias_domain_maps.cf, proxy:mysql:/etc/postfix/mysql_virtual_alias_domain_catchall_maps.cf
virtual_alias_recursion_limit = 1000
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf, proxy:mysql:/etc/postfix/mysql_virtual_alias_domain_mailbox_maps.cf

and some more info that may be of interest

myhostname = somedomain.com
mydestination = localhost.$mydomain, localhost, mail.somedomain.com
relayhost =

/etc/aliases file

# /etc/aliases
mailer-daemon: postmaster
postmaster: root
nobody: root
hostmaster: root
usenet: root
news: root
webmaster: root
www: root
ftp: root
abuse: root
noc: root
security: root
clamav: root
testing: info

althrough, without that testing line, email doesnt even bounce back

I can assure that virtual alias maps files are configured correctly, and mysql details are specifield there correctly but if needed, on request, I can provide them.

in /etc/postfix/master.cf the following line is added

dovecot   unix  -       n       n       -       -       pipe
flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -d ${recipient}

in /etc/dovecot/dovecot-sql.conf

driver = mysql
connect = host=localhost dbname=postfixadmin user=postfixadmin password=somepassword
default_pass_scheme = MD5
password_query = SELECT password FROM mailbox WHERE username = '%u'
user_query = SELECT maildir, 125 AS uid, 125 AS gid, CONCAT('maildir:storage=', FLOOR( quota / 1024 ) ) AS quota FROM mailbox WHERE username = '%u' AND active = '1'

in /etc/postfix/mysql_virtual_alias_maps.cf

user = postfixadmin
password = somepassword
hosts =
dbname = postfixadmin
query = SELECT goto FROM alias WHERE address='%s' AND active = '1'
#expansion_limit = 100

I am running out of ideas, what could the issue be in so any help is very much appreciated, thank you!

  • Ok, dovecot is correct there, how about the dovecot sql configurations? – NickW Mar 11 '14 at 11:51
  • I assume you mean /usr/share/dovecot/dovecot-sql.conf? What exactly about it. For me, whole file is commented out, how should it be? Or are you talking about these files? mysql_virtual_alias_domain_catchall_maps.cf mysql_virtual_alias_domain_mailbox_maps.cf mysql_virtual_alias_domain_maps.cf mysql_virtual_alias_maps.cf mysql_virtual_domains_maps.cf mysql_virtual_mailbox_maps.cf – Screatch Mar 11 '14 at 12:54
  • Well, if the users and aliases are in MySQL, how is dovecot going to be able to figure out who or what they are without being able to get that information from MySQL? – NickW Mar 11 '14 at 13:00
  • So i added a block of code to /etc/dovecot-sql.conf but still can't get it to work. – Screatch Apr 24 '14 at 8:30
  • It looks actually, like dovecot is doing it's job, but mysql is not expanding the alias to the original user. Is the alias a virtual domain? – NickW Apr 24 '14 at 8:40

The problem, as indicated, is that dovecot has no idea who the alias is, because it is not actually an email account. postfix should be telling it which account(s) to deliver it to. Either your mysql_virtual_alias_maps (if the user is in the virtual domains) or /etc/aliases is not expanding, and the alias (instead of the actual mailbox) is being passed to dovecot.

Edit: In fact, there was an option set in Screatch's main.cf receive_override_options = no_address_mappings which is often used to prevent aliases (and other mappings) from being expanded before being passed to content filters. In his case, there was no content filter, and this was preventing his aliases from being expanded before postfix passed it to dovecot to deliver.

| improve this answer | |
  • Nick saved me months of headache, indeed, problem was in receive_override_options, I just commented it out and it all started working. Thank you Nick! – Screatch Apr 24 '14 at 12:06
  • Oh My God, You are a Genius. I have been looking for this fix all evening. I am actually frustrated that it was that simple. – The Lazy Coder Nov 17 '15 at 7:19
  • You really are a genius. After making thousands of 'this-could-fix-it' changes, i almost gave up. This saved me when optimizing my smtpd_recipient_restrictions and moving from LDA to LMTP. – weeheavy Feb 2 '17 at 23:03
  • Glad to hear I helped :) – NickW Apr 27 '17 at 9:47

November 2015 update.

Same problem, alias did not work.

So I went to /etc/postfix/main.cf and changed (default) :

local_recipient_maps = unix:passwd.byname


local_recipient_maps = unix:passwd.byname $alias_maps

and now it works

| improve this answer | |

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.