How can I recieive confirmation for delivered email with JavaMail API?(如何使用 JavaMail API 接收已发送电子邮件的确认?)
问题描述
我正在编写一个程序,它发送电子邮件并想知道接收者何时收到我发送给他的电子邮件.如何使用 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?
如果我使用 SMTPMessage,我设置了通知选项后,具体如何处理结果?
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);
推荐答案
没有标准的方法可以被广泛接受和尊重.不过,我看到您有一些选择:
There is no standard way of doing this that's accepted and honored across the board. I see that you have some options, though:
在值中添加带有您的电子邮件地址的标题Return-Receipt-To".如果电子邮件的收件人有一个认可此标头的客户,则在打开电子邮件时会向您发送回执.请注意,这并不可靠,因为用户总是可以决定不发送收据,即使他有支持它的客户端.
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.
这篇关于如何使用 JavaMail API 接收已发送电子邮件的确认?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 JavaMail API 接收已发送电子邮件的确认?
基础教程推荐
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 降序排序:Java Map 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01