Using JavaMail API ina proxy server?

J

John Antypas

OK, how's this one for interesting?

I need a way to use JavaMail inside a Java-based SMTP proxy. In theory, the
proxy would run, and, upon receiving a message, hand that off to filters
which would use the JavaMail API for message handling. If the filter
passes, then the Java API could do its real work and talk to the real MTA.

1. Can I make JavaMail accept a stream from me to parse messages into
objects?
2. If not, could I createa session somehow that uses my proxy rather than a
traditional store?
 
G

GaryM

1. Can I make JavaMail accept a stream from me to parse messages
into objects?

Javamail requires an MTA to deliver mail and can handle a couple of
transports for retrieving mail. To employ it in a streaming real time
manner, IMO, was not the intention of the orginal designers.

In reality such an application will need to be an SMTP Server that,
as a final step, converts the received SMTP byte stream to a
javax.mail.MimeMessage, so that you can use it's message querying /
filtering to do what you want to do.

Presumably then, you would use the same SMTP server to move it on to
the mail store (Javamail can contact the Transport for you and pass
it for delivery). Note your SMTP Server would also have to write code
to write to the mail store.

In short, Javamail helps you with the message object, the querying
and the final delivery, all of which are not really your headache.
It's all the SMTP conversation stuff and platform specific mail
stores.

I think Apache Foundation's "James" project may be of interest to you
as it employs "mailets" to easily incorporate spam filters, and it
already is an SMTP/POP3/IMAP4 (and even a USENET) server.
2. If not, could I createa session somehow that uses my proxy
rather than a traditional store?

Various SMTP servers have a ways of taking raw rfc822 formatted
messages for delivery. For example

'sendmail -oi (e-mail address removed) < mymessage.eml'

will pass a raw message for delivery. You could use javamail to
retrieve mail from, eg, a POP3 store and once it passes the filters,
submit it to the SMTP server for final delivery. The issues are
obviously, how often to you poll for messages and what happens if
someone checks in between polls ... I'd feel more comfortable with
the Apache James approach.

HTH,

Gary
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top