views:

125

answers:

3

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);
A: 

please see my answer here (when this questioned was asked about ruby on rails). Tis basically the same answer.

http://stackoverflow.com/questions/3525145/email-open-notification-ruby-on-rails/3525199#3525199

Doon
+2  A: 

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.

Erick Robertson
Thanks! Now I'm reading about SMTPMessage ( http://java.sun.com/products/javamail/javadocs/com/sun/mail/smtp/SMTPMessage.html ) and maybe it is a solution to my problem.
brain_damage
A notification on SMTPMessage is going to notify you of successful delivery to the recipient's mailbox server, not to their desktop, or that they read it.
Erick Robertson
oh, I made a mistake, sorry. I meant I need a notification when the message is delivered.
brain_damage
Then I think you have found your solution. This should happen almost immediately.
Erick Robertson
A: 

You can use SMTP message and request for a delivery status (I don't know if it's coming when the provider receive the mail or if it's when the user open the mail). JavaMail don't support directly these feature directly and you have to read the RFC 3464. I also find this thread with examples but didn't try it javamail

You can also look at websina

oyo