I have an alias which has 20 mails accounts. So when a mail is sent to this alias, everyone receives it. But, when I set a vacation on one of those 20 mail accounts, the autoreply is sent as well. I want to exclude these cases - when the mail has not specific mail account in To: or Cc: header. The script is called vacation.pl and it's from postfixadmin.
Is there any way how to do it except for manual editing the script ?
The short answer is "No". At least if your setup and script is similar to mine.
Today I had a closer look at the vacation.pl we use in combination with Postfixadmin.
I assume that it is the same, but one can never be sure, so be careful. In the first lines of the script it say the following about the version:
In our case the activation of an automatic reply adds an entry like the following in the alias table of postfix:
Which means that the email will be save to the mailbox of the User and forwarded to the autoreply-domain (autoreply.example.org).
In a transportmap there is a the following entry, which will pass the mail to the vacation service as defined in master.cf:
For completeness here is the entry in my master.cf:
This means, that the vacation.pl script is triggered after the aliases have been resolved.
So if you want to prevent automatic replies to emails, that have been sent to an alias you will need to add a function to the script, which will check the X-Original-To-Header, so you can make sure if the mail was sent to an Alias with more than one recipient.
Around line 312 a function find_real_address is defined. This function will search for the real address (user).
It could be possible to use a modified version this function in combination with the emailaddress in the X-Original-To-Header to only send an automatic reply if the emailaddress is not one of an alias with multiple recipients.
I have not tried any of the above suggestions yet, so be careful.
It all depends on where your vacation reply is generated; normally, this is done with a link to a script in the .forward file for the users' mailbox.
Since this does not work for virtual mailboxes, several alternatives exist - using a dedicated filter, transport, MDA, or milter.
And probably more.
You'll have to provide more detailed information, including at least the output from
postconf -n
and any map files that are relevant to this scenario.Also include logging of a message being sent to this distribution list alias, and the resulting messages including the vacation reply.
I was looking for the same thing, I'm running my email server using Webmin, the autoreply mails are executed using the script
/etc/webmin/virtual-server/autoreply.pl
By reading it I find this block:
So I added an other condition
$header{'to'} =~ /my_alias_name_here/i ||
that way it will never send autoreply to any email sent to that alias.This is a quick hack, maybe I'll have some time later to make it list all the alias from the server. If you did it before please share the script :)
We fixed the above issue by changing two things:
1) Passing the original recipient instead of the recipient from the postfix to the vacation.pl script:
2) Adapting the vacation.pl script so it is not sending vacation-messages for aliases with multiple recipients.
...