Vacation autoreply to ALIAS on same server
short description
We have several virtual mail domains on the same server, and some users have configured aliases for their mail addresses. This all works fine. The problem is related to vacation autoreply, and ONLY in the following case:
- A user on our server has enabled autoreply
- A different user on our server emails to the first user from an alias (not their real mailbox).
In this case the autoreply is triggered via sieve, but then dovecot does not deliver it. The log is the following:
Mar 5 08:53:20 platano dovecot: lda(email1@domaim1.com): sieve: msgid=d2e92074-a11a-7627-7633-8d560425435a@netuxo.coop: sent vacation response to emailalias2@domain2.com Mar 5 08:53:20 platano postfix/pipe12074: DB02811C447F: to=emailalias2@domain2.com, relay=dovecot, delay=0.05, delays=0.03/0.01/0/0.02, dsn=5.1.1, status=bounced (user unknown)
I tracked it down to the following SQL in /etc/dovecot/dovecot-sql.conf:
user_query = SELECT email as user, maildir as home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND disable%Ls
= 'n' AND server_id = '6'
As relay is via dovecot, and this SQL query does not check for aliases, the user is unknown (as it is an alias).
correct behaviour
Either we should use a different relay, or dovecot should know what to do and expand the alias.
environment
Server OS: (debian)
Server OS version: (stretch)
ISPConfig version: (3.1.x)
you can use grep 'ISPC_APP_VERSION' /usr/local/ispconfig/server/lib/config.inc.php
to get it from the command line
proposed fix
I went down the second route (dovdcot) and changed the SQL to:
user_query = SELECT email as user, maildir as home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user LEFT OUTER JOIN mail_forwarding ON mail_user.email = mail_forwarding.destination WHERE (login = '%u' OR email = '%u' OR (mail_forwarding.source = '%u' AND mail_forwarding.server_id = '6' AND mail_forwarding.type = 'alias')) AND disable%Ls
= 'n' AND mail_user.server_id = '6' GROUP BY email
This seems to do the trick