This
feature offers a way to filter incoming emails by providing the ability
to execute
external programs, such as scripts or real executables, that examine
(modify or both) the message and give a response by the means of a return
value:
96: the email is OK and can continue its trip
97: the email is rejected without notification and is deleted
98: the email is rejected without notification but kept
on disk
99: the email is rejected and a notification is sent to
the sender
100: the email is modified and can continue its trip
When
a message is received by the SMTP server for user foo@xyzw.abc
then
XMail searches ins the filters subdirectory to find a file named (user
processing):
foo@xyzw.abc.tab
If
this file is not found then XMail will look for (domain processing):
xyzw.abc.tab
If
this file is not found then XMail will search a file called ".tab"
in the filters subdirectory. This offers a way to specify a default mail
filtering active for all the domains. If
this file is not found then the message will continue its travel, otherwise the message
will be submitted to all the filters specified in the *.tab file.
Note:
To create a file called ".tab" under Windows open a DOS
box and type: echo . > .tab
(Windows will not allow you to create such a file from Explorer -the
file manager)
The
syntax of the *.tab file is:
"command"[TAB]"arg-or-macro"[TAB]...[NEWLINE]
Ex:
"C:\MailRoot\bin\MyFilter.exe"[TAB]""C:\MailRoot\bin"[TAB]"@@FILE"
This
will invoke the program MyFilter.exe to check all incoming emails.
And
arg-or-macro can be:
@@FROM
will be substituted with the sender of the message
@@RCPT
will be substituted with the target of the message
@@FILE
will be substituted with the message file path (the external
command may modify the
file if it's going to return 100 as command exit
value)
@@MSGID
will be substituted with the (XMail unique) message id
@@MSGREF
will be substituted with the reference SMTP message id
Here
"command" is the name of an external program that must
process the
message and return a code. If it returns 99 then the message is rejected
and
a notification message
is sent to the sender. By returning 98 the message will be rejected
without notification while
by returning 97 the message is rejected without notification and without
being frozen (a 98 response could lead to a frozen message if the SERVER.TAB
configuration file enabled this).
Note:
If a filters returns a value different from 99, 98 or 97 then the message
can
continue its trip.
The
filter command may also modify the file and return 100, having the ability
to
change the file content (AV scanning, content filter, message rewriting,
etc.).
If
the filter changed the message file then it MUST keep the message structure
and it
MUST terminate all the lines with a <CR><LF>.
The
spool files have the following structure:
SmtpDomain
[ 1st line ]
SmtpMessageID
[ 2nd line ]
MAIL
FROM:<...> [ 3th line ]
RCPT
TO:<...> [ 4th line ]
<<MAIL-DATA>>
[ 5th line ]
...
After
the "<<MAIL-DATA>>" tag (5th line) the
message follows. The message
is composed by a header section and, after the first empty line
(CR-LF), the message body.
To
get the C/ C++ source code of ready-to-use email filters visit:
http://www.twd-industries.com/en/xmail.htm
// To patch attachments and HTML Tags
http://software.dolist.net/xscanner.asp
// To scan emails with a list of keywords
|