#56 End user customization of header strings

closed-fixed
nobody
Vacation (11)
5
2013-12-01
2009-06-27
Charles
No

Hi all,

I've been meaning to post this FR for a while...

How hard would it be to provide the ability to configure the header strings that the vacation.pl script uses to determine when NOT to send a vacation auto-response?

For example, in ASSP (also a perl script), in the GUI interface, it has options that have a textbox that can take either a reference to a file - ie, file:filename, where each line in the file would be a different string, or just a comma separated list of strings...

(see attached for an example of how this looks in the ASSP GUI)

This way, non-programmers like myself would have the ability to adjust these values, and add to (or subtract from) them, without having to resort to trying to edit the actual vacation.pl script.

Discussion

  • Charles
    Charles
    2009-06-27

    ASSP Options - files

     
    Attachments
  • GingerDog
    GingerDog
    2009-06-29

    it's probably not difficult to do, although i'm not sure I know a good way to do it in perl....

     
  • Charles
    Charles
    2009-06-29

    Me neither... ;) thats why I included the link to the assp projects example gui page...

    I was hoping someone could use the assp.pl script as an example of how to do it...

    ASSP project download page is:

    https://sourceforge.net/projects/assp/

     
  • Charles
    Charles
    2011-10-10

    Here is an example of an email that our system sent a vacation response to this morning that should not have been sent:

    mailhost : Fri Oct 07, 15:52:48 : ~
    # grep 7403988D6AC /var/log/messages
    Oct 10 06:59:37 mailhost postfix/smtpd[13273]: 7403988D6AC: client=sv4-mta-52a.emailfiltering.com[208.87.136.233]
    Oct 10 06:59:37 mailhost postfix/cleanup[13278]: 7403988D6AC: message-id=<00000132ed7cd8eb-4cee52b7-00f4-4eef-9abd-e08463e21bb3-000000@email.amazonses.com>
    Oct 10 06:59:37 mailhost postfix/qmgr[10236]: 7403988D6AC: from=<00000132ed7cd8eb-4cee52b7-00f4-4eef-9abd-e08463e21bb3-000000@email-bounces.amazonses.com>, size=11814, nrcpt=2 (queue active)
    Oct 10 06:59:37 mailhost postfix/virtual[13280]: 7403988D6AC: to=<user@media-brokers.com>, relay=virtual, delay=0.43, delays=0.42/0.01/0/0.01, dsn=2.0.0, status=sent (delivered to maildir)
    Oct 10 06:59:38 mailhost postfix/pipe[13279]: 7403988D6AC: to=<user#media-brokers.com@autoreply.media-brokers.com>, orig_to=<user@media-brokers.com>, relay=vacation, delay=0.81, delays=0.42/0.01/0/0.39, dsn=2.0.0, status=sent (delivered via vacation service)
    Oct 10 06:59:38 mailhost postfix/qmgr[10236]: 7403988D6AC: removed
    mailhost : Mon Oct 10, 07:07:14 : ~

    If I could easily add 'email-bounces' string to a list of - call them 'veto strings' - used to determine when not to send a vacation message, this would be easily handled, but alas, it isn't...

    Any ideas anyone on how to do this? I don't even mind a way to do it manually by directly adding a new line to the vacation.pl script, but my earlier attempts at doing that failed...

    Ultimately though, I really think there should be a simple way to do this via the GUI...

     
  • Charles
    Charles
    2013-03-12

    Ok, with the most kind help of Rudi, I was finally able to get this working, and even got it working using vacation.conf (I'd still love to see this added to the GUI, but this is good enough for me right now)...

    I will supply a diff against the vanilla 2.3.6 vacation.pl soon that will properly modularize the code blocks, but for anyone interested, here is the quick-n-dirty...

    (I'm including some lines before and/or after each block for context so you know where it goes)

    In vacation.pl (towards the top where user edits go):

    # By default vacation messages will be sent to all senders that can not
    # definitively be determined to be email lists or other senders that
    # should not be auto-replied to.
    # To enable the $custom_noreply option change it to 1, then you can modify
    # the list of strings in line xxx of the main vacation.pl script. These strings
    # are tested against both the envelope sender and all from headers, and if a
    # match is found, no message is sent.
    our $custom_noreply = 0;
    # variable to define the custom do-not-reply strings as a variable
    our $custom_noreply_pattern = 
    'bounce|do-not-reply|facebook|linkedin|list-|myspace|twitter';
    
    # instead of changing this script, you can put your settings to /etc/mail/postfixadmin
    # /vacation.conf or /etc/postfixadmin/vacation.conf just use Perl syntax there to fill
    # the variables listed above (without the "our" keyword). Example:
    

    and the actual code executed:

    # If either From: or To: are not set, or if $custom_noreply is enabled and the sender
    # address and/or from header(s) contain(s) any of the strings in the parenthesis below,
    # exit
    if(!$from || !$to || !$messageid || !$smtp_sender || !$smtp_recipient) {
        $logger->info("One of from=$from, to=$to, messageid=$messageid, smtp_ sender=$smtp_sender, smtp recipient=$smtp_recipient empty");
        exit(0);
    }
    # Be very careful modifying the strings in $custom_noreply_pattern if $custom_noreply
    # is true.
    # The defaults are: (bounce|do-not-reply|facebook|linkedin|list-|myspace|twitter)
    if($custom_noreply && ($from =~ /^.*($custom_noreply_pattern).*/i)) {
        $logger->info("Mail from $from matches custom do-not-send string and shouldn't be auto-replied to.");
        exit(0);
    }
    $logger->debug("Email headers have to: '$to' and From: '$from'");
    

    Then, in vacation.conf:

    # By default vacation messages will be sent to all senders that can not
    # definitively be determined to be email lists or other senders that
    # should not be replied to. You can enable $custom_noreply option, then
    # modify the list of strings in $custom_noreply_pattern. These strings
    # are tested against both the envelope sender and all from headers, and
    # if a match is found, no message is sent.
    $custom_noreply = 1;
    $custom_noreply_pattern = 
    'alert|autoreply|bounce|constantcontact|do-not-reply|facebook|linkedin|list-|myspace|newsletter|noreply|no-reply|twitter';
    
     
  • Charles
    Charles
    2013-03-28

    This is now implemented in vacation.pl in trunk, implemented and merged thanks to Rudi (thanks again Rudi!).

    So, this can be closed as fixed (I'd do it myself but don't think I can)...

     
    • status: open --> closed-fixed
    • milestone: --> SVN_(please_specify_revision!)