SF.net SVN: postfixadmin:[532] trunk/VIRTUAL_VACATION/vacation.pl
Brought to you by:
christian_boltz,
gingerdog
From: <Gin...@us...> - 2009-01-20 13:22:30
|
Revision: 532 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=532&view=rev Author: GingerDog Date: 2009-01-20 11:53:54 +0000 (Tue, 20 Jan 2009) Log Message: ----------- vacation.pl: make it strip/discover addresses better, slightly better logging, stop it requiring a messageid Modified Paths: -------------- trunk/VIRTUAL_VACATION/vacation.pl Modified: trunk/VIRTUAL_VACATION/vacation.pl =================================================================== --- trunk/VIRTUAL_VACATION/vacation.pl 2009-01-20 11:49:03 UTC (rev 531) +++ trunk/VIRTUAL_VACATION/vacation.pl 2009-01-20 11:53:54 UTC (rev 532) @@ -152,6 +152,7 @@ my ($from, $to, $cc, $replyto , $subject, $messageid, $lastheader, $smtp_sender, $smtp_recipient, %opts, $spam, $test_mode, $logger); $subject=''; +$messageid='unknown'; # Setup a logger... # @@ -391,7 +392,7 @@ 'Message' => encode_base64($body) ); if($test_mode == 1) { - $logger->info("** TEST MODE ** : Vacation response sent to $to from $from subject $subject - NOT sent\n"); + $logger->info("** TEST MODE ** : Vacation response sent to $to from $from subject $subject (not) sent\n"); $logger->info(%mail); return 0; } @@ -410,13 +411,28 @@ } my @ok; $logger = get_logger(); - for (split(/,\s*/, lc($arg))) { - my $temp = Email::Valid->address($_); + my @list; + @list = $arg =~ m/([\w\.\-\']+\@[\w\.\-]+\w+)/g; + foreach(@list) { + #$logger->debug("Checking: $_"); + my $temp = Email::Valid->address( -address => $_, -mxcheck => 0); if($temp) { push(@ok, $temp); } + else { + $logger->debug("Email not valid : $Email::Valid::Details"); + } } - my $result = join(", ", @ok); + # remove duplicates + my %seen = (); + my @uniq; + my $item; + foreach $item (@ok) { + push(@uniq, $item) unless $seen{$item}++ + } + + my $result = join(", ", @uniq); + #$logger->debug("Result: $result"); return $result; } @@ -459,6 +475,7 @@ $cc = ''; $replyto = ''; +$logger->debug("Script argument SMTP recipient is : '$smtp_recipient' and smtp_sender : '$smtp_sender'"); while (<STDIN>) { last if (/^$/); if (/^\s+(.*)/ and $lastheader) { $$lastheader .= " $1"; next; } @@ -495,7 +512,7 @@ $logger->info("One of from=$from, to=$to, messageid=$messageid, smtp sender=$smtp_sender, smtp recipient=$smtp_recipient empty"); exit(0); } - +$logger->debug("Email headers have to: '$to' and From: '$from'"); $to = strip_address($to); $from = lc ($from); $from = check_and_clean_from_address($from); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |