POP3 scanning?

John Rudd jrudd at UCSC.EDU
Mon Sep 15 06:06:34 IST 2003


On Sunday, Sep 14, 2003, at 19:28 US/Pacific, Antony Stone wrote:

>
> On Monday 15 September 2003 3:23 am, S Mohan wrote:
>
>> One such proxy exists in sourceforge called emailproxy which is a
>> POP3 and
>> SMTP proxy. It has the capability to pipe either incoming "popped"
>> mail or
>> outgoing smtp thro' a commandline program - either a scanner or any
>> other
>> program. However, here I guess Mailscanner will be invoked for every
>> mail
>> as an instance. DO not know if it would be efficient.
>
> It is not the piping I have the problem with.
>
> The question is whether MailScanner can process the file format, since
> the
> scanned mails won't be queue files from some standard MTA such as
> sendmail or
> exim - they'll be mbox files.
>
> Thanks to everyone who is suggesting various proxy programs, but this
> really
> is a MailScanner question I'm asking here :)
>

My gateway scripts for CommuniGate Pro sort of work with rfc822 files
(the difference between mbox format and rfc822 is: a) mbox has multiple
messages, and rfc822 just defines one message, so technically an rfc822
format is just 1 message per file; b) the first line of an mbox file,
the "From_" line or "from envelope", isn't part of rfc822).  The
communigate pro queue file format is like rfc822, except:

first line has data on it (flags, time stamps, stuff like that), starts
with a "P", and the 8th word is the "mail from:" sender.

the 2nd line through the first blank line are in the same format,
except that they start with "R" and the 8th "word" is each of the "rcpt
to:" recipients.

(there might be other lines in there, before the first blank line, but
my script only looks at the lines that start P and R)

Then you've got a blank line.

Then you've got the rfc822 file (headers, then blank line, then the
body).

You could pretty easily construct such a file from an mbox using
formail (use the from_ line, which mbox uses as the first line of the
file, remove it, and then use its information to create the "mail from"
sender line that communigate pro uses; then construct the 2nd line by
just putting your final destination address on it, then put a blank
line and then the rest of the message; 1 file per message).  You don't
need the actual data from the first block of lines, as my script
doesn't use it -- you just need to make sure that the right addresses
are at the ends of the lines.  Then you could submit it to mailscanner
using my cgp2ms script (which converts from communigate pro queue file
format to sendmail queue file format).

The trick is getting them back from mailscanner when they're done.
You'd want to modify my ms2cgp script to take the output messages
(which are in sendmail queue file format) and build an mbox ... the
problem being that you don't know how long it'll take, due to the
asynchronous nature of mailscanner.  The ms2cgp script mostly converts
them back from sendmail queue file format into rfc822 format.
"formail", with the right arguments, can take those and convert them
back into an mbox.


my scripts are at:

http://people.ucsc.edu/~jrudd/MailScanner

The scripts are GPL.  Feel free to use them however you want, within
the bounds of the GPL.



More information about the MailScanner mailing list