I have coded in Java for years but never had to do anything with receiving email. Sending has always been a snap. Now, I have the problem and don't know how to address it.
I am looking for a way to pipe emails coming from a MTA (sendmail/postfix/Q-mail) to a java program. Ease enough to do this but what comes next?
After this step I want to grab an object representation of the email from the InputStream. I can not find anything that seems to do this! I have looked at javax.mail and Apache commons mail. I must be missing something.
I am getting the email as it is piped to the java application. We want to use this to audit and record certain emails. We need to receive it through this system before it is even delivered to the user.
This seems the only way to hook into mail servers in a generic manner.
Okay. So you are going to have to parse the text that you get from stdin. As I said before, either get the documentation from whatever package is writing the e-mails to stdout (and your pipe), or you will have to develop it yourself by looking at the data.
I have never heard of MTAs that output messages as text, but it sounds from your original post as if that is a fairly ordinary thing in your experience. Shouldn't be too hard to find the specs, then.
I feel better in one way since I searched everywhere thinking there would be a way to transform the InputStream into an object. Yet, I am surprised that there isn't something around to do this already. This is same stream data as an incoming SMTP connection.
Perhaps the few Java-based SMTP server projects like Apache James have something.
Yes, my master! Here is the tiny ad you asked for:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop