[Mimedefang] Mimedefang filter "From:" header

David F. Skoll dfs at roaringpenguin.com
Mon May 7 09:43:04 EDT 2007


Girardeau.GA at forces.gc.ca wrote:

> I want to filter information in the "From:" header.

> Example:
> From: "John Doe" <john.doe at johndoe.com>

> I am able to filter out the address but I would rather filter the "John
> Doe" portion.

[...]

> sub filter_sender {

filter_sender sees only the envelope sender (that is, the argument
of the MAIL FROM: SMTP command) and that will not include the full name.

To filter on headers, you need to wait until filter_begin and use
the file HEADERS.  You could do something like this:

sub filter_begin
{
        if (open(HDRS, '<./HEADERS')) {
	        while(HDRS) {
		        if (/^From:.*John Doe/i) {
			        close(HDRS);
			        return action_bounce("No spam please.");
			}
		}
		close(HDRS);
	}
	# ... rest of filter_begin
}

Regards,

David.



More information about the MIMEDefang mailing list