Results 1 to 4 of 4

Thread: [SOLVED] Running a script / program on successful delivery

  1. #1
    aratnaweera is offline Junior Member
    Join Date
    Oct 2009
    Posts
    5
    Rep Power
    5

    Default [SOLVED] Running a script / program on successful delivery

    Hi there,

    I want to run a script *after* each successful message delivery. This is to implement a custom delivery notification system and other things that can't be achieved by standard means.

    All I need is to run a program which takes the email address as an argument.

    I can code, so if this needs developing some hook/plugin, that also is ok.

    Thanks in advance.

    Anuradha

  2. #2
    aratnaweera is offline Junior Member
    Join Date
    Oct 2009
    Posts
    5
    Rep Power
    5

    Default

    I managed to get this done by hacking zmlogger. Couldn't run my own script by editing logswatchrc, which would have been neater. Here is what I added to zmlogger.

    Code:
    --- zmlogger.orig       2009-11-08 23:01:36.000000000 +0530
    +++ zmlogger    2009-11-08 23:17:05.000000000 +0530
    @@ -468,6 +468,13 @@
                 next if (!scalar @match);
                 ($csv_file, $csv_confirm, $headers, $data) = @match;
                 die "$csv_file != $csv_confirm" if ($csv_file ne $csv_confirm);
    +        } elsif ($app eq 'postfix/lmtp') {
    +           if ($msg =~ /.* to=<([^>]*)>, .* Delivery OK\)$/) {
    +               my $email = $1; 
    +               $email =~ s/[^a-zA-Z0-9@\._-]//g;
    +               system('/usr/local/sbin/notify.sh', $email);
    +           }
    +
             } else {
                 next;
             }
    Is there a better way of doing this?

  3. #3
    aratnaweera is offline Junior Member
    Join Date
    Oct 2009
    Posts
    5
    Rep Power
    5

    Default

    Quote Originally Posted by aratnaweera View Post
    I managed to get this done by hacking zmlogger.
    Unfortunately, the above didn't work out, as zmlogger is keeping an eye on /var/log/zimbra-stats.log and not zimbra.log.

    The following script worked, although not the neatest way of doing it. This requires File::Tail (libfile-tail-perl on Ubuntu).

    Code:
    #!/usr/bin/perl
    
    use strict;
    use File::Tail;
    
    my $log = File::Tail->new(name => '/var/log/zimbra.log', maxinterval => 2, interval => 1);
    my $logregex = qr/^.{15} ((\d+\.\d+\.\d+\.\d+)|(\S+)) postfix\/lmtp\[\d+\]: .* to=<([^>]*)>, .* Delivery OK\)$/o;
    
    while (defined(my $line = $log->read)) {
            chomp $line;
            if ($line =~ m/$logregex/) {
                    my $email = $4;
                    $email =~ s/[^a-zA-Z0-9@\._-]//g;
                    system("/usr/local/bin/notify.sh '$email'");
            }
    }

  4. #4
    aratnaweera is offline Junior Member
    Join Date
    Oct 2009
    Posts
    5
    Rep Power
    5

    Default

    Seems that this is the only way to get this done. Marking "solved".

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. could not send email on zcs 4.5.6
    By bylong in forum Installation
    Replies: 9
    Last Post: 08-20-2007, 09:02 AM
  2. Zimbra Install Problem - getDirectContext
    By bsimzer in forum Installation
    Replies: 27
    Last Post: 07-19-2007, 10:12 AM
  3. Getting problems in FC4 while instalation
    By kitty_bhoo in forum Installation
    Replies: 13
    Last Post: 09-12-2006, 10:34 PM
  4. Fedora Core 3, Clean Install - Not working!
    By pcjackson in forum Installation
    Replies: 17
    Last Post: 03-05-2006, 07:38 PM
  5. Network edition - strange behavior
    By goetzi in forum Installation
    Replies: 6
    Last Post: 11-16-2005, 03:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •