views:

323

answers:

2

Hello,

I am using Postfix smtp server for receiving mails.

My requirement is to take the mail objects from Postfix and parse the mail objects so that the individual mail objects can be used in my java code as soon as a mail is received by Postfix.

One of the solutions that i have come up is to have a content filter communicating with Postfix and taking the mails as streams on custom port and parse the mail stream to my java MIME message.

Currently i am able to have the mail stream from postfix but unable to parse that stream in my java filter code and get the required results.

Please help!!!

Thanks in advance!!

Ashish

+1  A: 

I think postfix uses the protocol LMTP to communicate here, it's specified in rfc 2033, which can be found here: rfc 2033

I sounds like you want to recreate the functionality of maildrop. I would look at the sourcecode for that project, it can be found here: maildrop source.

Alexander Kjäll
+1  A: 

To parse mail messages with Java, JavaMail is your best option. In order to communicate with Postfix as a content filter, you probably need to implement the LMTP protocol by yourself, or reuse parts of an existing SMTP server such as James.

Depending on what you're trying to accomplish, perhaps you could have Postfix deliver messages to a Maildir backend and then use JavaMail to access them with an IMAP client on a regular basis?

Martin