Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I recieive confirmation for delivered email with JavaMail API?

I'm writing a program, that sends email messages and want to know when the receiver receives the email message I've sent to him. How can I do this using JavaMail API?

If I use SMTPMessage, how exactly to deal with the result after I've set the notify options?

SMTPMessage smtpMsg = new SMTPMessage(msg);
smtpMsg.setNotifyOptions(SMTPMessage.NOTIFY_SUCCESS);
like image 823
brain_damage Avatar asked Sep 09 '10 13:09

brain_damage


People also ask

How do you check mail is delivered or not in Java?

you can check the messag object whether the email has sent or not by comparing its contents. I hope it will help you. Show activity on this post. By what I understand, the purpose of getting the code right after sending the email is to be able to determine if the sending of the email went well or not.

Which protocol is used to receive the messages in JavaMail?

IMAP: Acronym for Internet Message Access Protocol. It is an advanced protocol for receiving messages. It provides support for multiple mailbox for each user, in addition to, mailbox can be shared by multiple users. It is defined in RFC 2060.

How can I get SMTP server response using JavaMail?

SMTPTransport t = (SMTPTransport)session. getTransport("smtps"); t. send(message); String response = t. getLastServerResponse(); boolean s = t.


1 Answers

There is no standard way of doing this that's accepted and honored across the board. I see that you have some options, though:

  • Add a header "Return-Receipt-To" with your e-mail address in the value. If the recipient of the e-mail has a client which honors this header, then a return receipt will be sent to you when the e-mail is opened. This is not reliable, mind you, as the user can always decide not to send the receipt, even if he has a client that supports it.

  • Add an image into your e-mail that loads from your server and put a parameter on the image that includes the user's e-mail address. When the e-mail loads, the image will load from your server. Write a script that collects the e-mail parameter and then delivers a blank image. This is also not reliable, however, as many mail clients prompt users if they wish to download images and they can always choose not to. Also, some (mostly older) e-mail clients do not support images.

  • Perhaps the most reliable way is not to include the message in your e-mail at all. Include only a link to a website where the message can be read, and include their e-mail address or a unique code in the link. This way, you know exactly who read the message. Of course, this has the downside that people aren't actually getting the message in their inbox, and they also may choose not to go to the website to read it.

Ultimately, I think you're going to have to come up with a creative solution to solve this problem, unless you're happy getting spotty results.

like image 191
Erick Robertson Avatar answered Oct 29 '22 08:10

Erick Robertson