This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Rust Web Development and have Bastian Gruber on-line!
See this thread for details.
Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Email From Stdin - API?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 26957
84
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 26957
84
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
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
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic