View Full Version : Postfix regex
cyrus1977
5th January 2011, 22:11
Maybe a good idea for a thread.
Post your regex examples here in this thread, so others can benefit.
falko
6th January 2011, 15:16
This is from the ISPConfig 3 Manual (http://www.ispconfig.org/ispconfig-3/ispconfig-3-manual/) - these are regular expressions for Postfix header and body checks:
Regexp. Pattern: Filter Type: Explanation:
/^Subject: .*Make Money Fast!/ Header Filter Searches for the string Make Money Fast! in the Subject line.
/name=[^>]*\.(bat|com|exe|dll)/ MIME-Header Filter This will match all messages that have attachments whose files end in .bat, .com, .exe or .dll.
/^<iframe src=(3D)?cid:.* height=(3D)?0 width=(3D)?0>$/ Body Filter Body pattern to stop a specific HTML browser vulnerability exploit.
/^From: joe@example.com/ Header Filter Matches all messages sent by joe@example.com.
/^From: .*@example.com/ Header Filter Matches all messages sent from the example.com domain.
/Real Bad Words/ Body Filter This matches "real bad words" in any case (upper, lower, or mixed).
/^Date: .* 200[0-2]/ Header Filter This matches all emails sent in the years 2000 - 2002.
/^Date: .* 19[0-9][0-9]/ Header Filter This matches all emails sent between 1900 and 1999.
/^To: postmaster@yourdom.ain/ Header Filter Matches all messages sent to postmaster@yourdom.ain.
cyrus1977
7th January 2011, 23:08
thank but actually i was more looking for custom filters other users made.
Here is a more fine tuned one out of the manual:
Regexp. Pattern: Filter Type: Explanation:
/^Content-(Disposition|Type).*name\s*=\s*"?(.*\.(bat|exe|scr|lnk|com))(\?=)?"?\s*(;|$)/x MIME-Header Filter This will match all messages that have attachments whose files end in .bat, .com, .exe or .dll.
What i dont understand is what the difference is betwee reject (does a warning go out), ignore and discard.
Can you shed some light on it ?
Added two cronjobs aswell related to messages who where hold.
10 2 * * * find /var/lib/amavis/virusmails/ -type f -mtime +31 -exec rm {} \;
15 2 * * * find /var/lib/amavis/tmp/ -type f -mtime +31 -exec rm -r {} \;
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.