[Mimedefang] Problem matching occurrences other than first line in email.

Lars Sorensen lars at daxzuli.com
Tue Apr 2 05:30:22 EDT 2013


Hello,

Trying to get heads and tails of Mimedefang and Perl, I'm stuck understanding why the below code in Mimedefang will only match on the first line of an email and ignore the rest.

So:
"open something anotherthing thirdthing" only matches if on the first line of the email, and additional lines are ignored.
I'm trying to match all occurrences of lines with this pattern and add headers accordingly.
Can anybody throw me a bone on this one?

###########################################################################
sub filter {
	my($entity) = @_;
	
	if (grep {/email\@example\.com/i} @Recipients) {
		my $io;
		if ($io = $entity->open("r")) {
			while (defined($_ = $io->getline)) {
				if  ( $_ =~ /\bopen\W+([a-z]+)(\W+)?([a-z]+)?(\W+)?([a-z]+)?/i) {
					action_add_header('X-header',"$1, $3, $5");
					last;   
				}
			}
        	$io->close;
        	}
	}
}
###########################################################################

All the best

Lars Sorensen




More information about the MIMEDefang mailing list