2

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 ?

4 Answers 4

1

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:

# Virtual Vacation 4.0
# $Revision: 893 $

In our case the activation of an automatic reply adds an entry like the following in the alias table of postfix:

[email protected]@autoreply.example.org,[email protected]

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:

   autoreply.example.org    vacation:

For completeness here is the entry in my master.cf:

vacation unix - n n - - pipe
  flags=Rq user=vacation argv=/var/spool/vacation/vacation.pl -f ${sender} ${recipient}

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.

0

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.

0

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:

if ($header{'x-mailing-list'} ||
$header{'list-id'} ||
$header{'precedence'} =~ /junk|bulk|list/i ||
$header{'to'} =~ /Multiple recipients of/i ||
$header{'from'} =~ /majordomo/i ||
$fromline =~ /majordomo/i) {
    # Do nothing if post is from a mailing list
    exit 0;
    }

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 :)

0

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:

vacation    unix  -       n       n       -       -       pipe
  flags=Rq user=vacation argv=/usr/lib/postfixadmin/vacation.pl -f ${sender} -- ${recipient}

vacation    unix  -       n       n       -       -       pipe
  flags=Rq user=vacation argv=/usr/lib/postfixadmin/vacation.pl -f ${sender} -- ${original_recipient}

2) Adapting the vacation.pl script so it is not sending vacation-messages for aliases with multiple recipients.

#MC        my $vemail = $email;
#MC        $vemail =~ s/\@/#/g;
#MC        $vemail = $vemail . "\@" . $vacation_domain;
#MC        $logger->debug("Looking for alias records that '$email' resolves to with vacation turned on");
#MC        my $query = qq{SELECT goto FROM alias WHERE address=? AND (goto LIKE ? OR goto LIKE ? OR goto LIKE ? OR goto = ?)};
#MC        $stm->execute($email,"$vemail,%","%,$vemail","%,$vemail,%", "$vemail") or panic_execute($query,"address='$email'");
        $logger->debug("Looking for alias records that '$email' resolves to with vacation turned on");
        my $query = qq{SELECT goto FROM alias WHERE address=?};
        my $stm = $dbh->prepare($query) or panic_prepare($query);
        $stm->execute($email) or panic_execute($query,"address='$email'");
        $rv = $stm->rows;

...

#MC do not send away-message to alias with multiple recipients
#                for (split(/\s*,\s*/, lc($alias))) {
#                    my $singlealias = $_;
#                    $logger->debug("Found alias \'$singlealias\' for email \'$email\'. Looking if vacation is on for alias.");
#                    $rv = check_for_vacation($singlealias);
## Alias has vacation
#                    if ($rv == 1) {
#                        $realemail = $singlealias;
#                        last;
#                    }
#                }
                $logger->debug("Found multiple aliases \'$alias\' for email \'$email\'. Thus, not sending vacation reply.");
                $realemail = $email;
                $rv = 0;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .