How do I receive an acknowledgement that a user has received my message?

John Zukowski

There is an SMTP extension that supports Delivery Status Notifications (DSN) defined in RFC 1891. This may or may not be supported by the user's Mail Transport Agent (MTA).

To receive the acknowledgements, you'll need to set two properties in the Properties passed on when getting a Session. These are "mail.smtp.dsn.notify" and "mail.smtp.dsn.ret". The first specifies where it goes and the second what you want.

  "SUCCESS,FAILURE ORCPT=rfc822;recip@foo.bar");
props.put("mail.smtp.dsn.ret", "HDRS");

For a full description of the meaning see the RFC. If you want the full message sent back to you, use FULL instead of HDRS. recip@foo.bar is meant to the original recipient of the email.

Be sure to change the address to send the acks to a more appropriate email.

These acks are not about when the user reads the message, only acknowledging receipt of the message by their mail server. Its possible the mail server throws the message away as spam for instance and the end user never actually gets the message in their mailbox.

Another option, though something that can be ignored by the mail client / user is setting the "Disposition-Notification-To" header to the email you'd like to send the notification to: