• Post Reply Bookmark Topic Watch Topic
  • New Topic

Email From Stdin - API?  RSS feed

 
Sean Muse
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

All replies are welcome.


- Z
 
Paul Clapham
Sheriff
Posts: 22829
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suppose you must be getting the e-mails in some text format. If there's no documentation about the format then perhaps you will have to reverse engineer it to find out how to process it.

JavaMail wasn't designed for that sort of thing. It was designed to interact directly with the mail servers, rather than with the output of something else that's interacting with the server.

Is the requirement for dealing with the serialized text version of e-mail messages something you can change? Personally I would prefer to use JavaMail to access the mail server directly.
 
Sean Muse
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.


- Z
 
Paul Clapham
Sheriff
Posts: 22829
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sean Muse
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.



- Z
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!