Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 421
Jasper Avatar asked Apr 20 '13 15:04

Jasper


People also ask

Can a web server send email?

In order to send emails from your website, localhost has to be assigned as SMTP host name and port 25 should be used. Authentication or secure connection (SSL/TLS) is not required.

Can be used to send or receive the mails on the Internet?

Electronic mail (e-mail), a system that allows users to send and receive messages through a computer network, is the most common groupware application and a central component of several other groupware tools based on a messaging system.


1 Answers

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

like image 126
kolossus Avatar answered Oct 05 '22 09:10

kolossus