Jasper
Jasper

Reputation: 8705

Send/Receive Email from within Web Application?

I have an Order Management (Web) Application (in Java/Java EE).

The application users want to Send Receive email communication to Customers who placed the Order, from within the Web-Application. The Email Trail must be associated with the Order.

The use-case is:

  1. User opens the Order Detail Page. Order info. is displayed.
  2. On that page - Clicks on Email Icon, and it will show up all Email Communication (sent/received) for that Order till date.
  3. For that Order - You can see new incoming mails, reply to mails or send out new mails to the Customer - all related to that Order.

Questions:

  1. Sending out emails is easy, but how to receive emails within the app?
  2. What is the email account here - A common Email Account called [email protected] (and based on subject line/some-header emails are filtered etc.) or is it [email protected] (in which case new email acct creation is reqd per order) or ?
  3. We already have Microsoft Exchange Server via which company email travels. Could we leverage that in someway or do we need to setup a new Mail Server?

Any ideas are welcome.

Upvotes: 8

Views: 6112

Answers (4)

kolossus
kolossus

Reputation: 20691

If you're willing to take on the dependency, Spring Integration can comfortably read email from a designated server on a polling (POP3, IMAP) or event-driven basis (IMAP-IDLE). [1 & 3]

[2] You can use a dedicate mail account and filter the mail sent to downstream channels based on the subject (or other field) of the incoming mail. The following snippet from the Spring site illustrates this:

   <int-mail:imap-idle-channel-adapter id="customAdapter"
store-uri="imaps://some_google_address:${password}@imap.gmail.com/INBOX"
channel="receiveChannel"    
should-mark-messages-as-read="true"
java-mail-properties="javaMailProperties"
mail-filter-expression="subject matches '(?i).*Spring Integration.*'"/>

Where mail-filter-expression filters the email that will be flushed down receiveChannel. For all interested parties (channels), you'll have one <int-mail:imap-idle-channel-adapter/> listening to your Exchange server.

While it's not cumbersome to use, I'd recommend you look at a short overview of EAI according to spring and of EAI in general

Upvotes: 5

tgkprog
tgkprog

Reputation: 4598

From a user point of view I think keeping a specific subject is more difficult. I would suggest a sub domain like myapp.myorg.com or a new domain like myapp.com

Either ways have a catch all so that all mails go to a specific email like [email protected]

Then your script can check the real TO. This might be more natural and 'cool' -> each order has its own mail id! On top of that use James or other mail software to get delivery to your code.

Upvotes: 1

Gladwin Burboz
Gladwin Burboz

Reputation: 3549

  1. Receive emails Here is example code to read an email Are there any good short code examples that simply read a new gmail message?

  2. Email account here For each user create an email account and have user's web app credentials used as credentials for email as well. Use hashed order id as part of subject to relate each email chain to specific order.

  3. Microsoft Exchange Server Use either exJello is a JavaMail provider (http://www.exjello.org/) OR Use JavaMail API with DavMail Gateway (http://davmail.sourceforge.net/)

Upvotes: 3

IndoKnight
IndoKnight

Reputation: 1864

You need the following.

  1. Java Mail API to programmatically send emails through some exchange server.
  2. I would suggest to use a dedicated email server to receive application specific emails. You can do this by using James. You can send and receive emails through this software.
  3. If you use your existing Microsoft Exchange Server, you can always use redirect to your application specific email server.

Upvotes: 3

Related Questions