发送电子邮件并检查状态

发布于 2024-07-06 00:51:29 字数 316 浏览 8 评论 0原文

使用Java邮件,我想发送一封电子邮件并检查状态。 可能的状态包括:

  • 硬退回:未找到邮件服务器
  • 软退回:已找到邮件服务器,但未找到帐户
  • 成功

是否可以按照我所描述的方式发送电子邮件并获得有关投递尝试的一些反馈多于?

编辑:受访者建议寻找一个提供与 ListNanny。 我四处寻找,但没有发现任何东西。 知道这样的图书馆是否存在吗?

Using Java mail, I would like to send an e-mail and check the status. Possible statuses include:

  • Hard-bounce: No mail server found
  • Soft-bounce: Mail server found, but account not found
  • Success

Is it even possible to send an e-mail and get some feedback about the delivery attempt in the manner I've described above?

EDIT: A respondent suggested looking for a Java library that provides the same functionality as ListNanny. I've searched around, but haven't found anything. Any idea if such a library exists?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

撩起发的微风 2024-07-13 00:51:29

您无法可靠或一致地做到这一点。 如果您的本地邮件服务器将其传递到公司的外发邮件服务器,然后当该服务器尝试传递它时邮件被退回,会发生什么情况? 如果邮件服务器无法与其他邮件服务器通信并且消息在 4 天后超时,会发生什么情况?

You can't do this reliably or consistently. What happens if your local mail server passes it onto a corporate out-going mail server, and then it bounces when that server tries to pass it on? What happens if the mail server can't talk to the other mail server and then the message times out after 4 days?

笔芯 2024-07-13 00:51:29

如果您要发送 HTML 电子邮件,您可能需要在电子邮件中嵌入 1 像素透明图像。 图像 URL 实际上会引用返回图像的 servlet。 URL 还会有某种消息 ID 作为参数。
这背后的想法是,当用户阅读消息时,他/她会显示图像,这会触发您的 servlet,该 servlet 会将消息已被读取的信息写入数据库。

If you're sending out HTML email, you might want to embed a 1 pixel transparent image in the email. The image URL would actually reference a servlet that returns the image. The URL would also have some sort of message id as a parameter.
The idea behind this is that when the user reads the message, he/she displays the image, which triggers your servlet, which writes to the db that the message had been read.

长途伴 2024-07-13 00:51:29

您需要做的是将信封 SMTP 发件人设置为您监控 NDR 邮件的地址。 您必须在收到电子邮件时对其进行解析并找出问题所在。 这通常用于邮件列表,并且像 ListNanny 这样的产品用于处理消息(它是一个 .NET产品,但我确信有一个 Java 等效产品,或者您可以自己编写)。

信封“发件人”与邮件“发件人”地址不同。 它是代码和 MTA 之间发生的 SMTP 对话的一部分。 所有 NDR 将发送至该地址。

What you have to do is set the envelope SMTP sender to an address you monitor for NDR messages. You have to parse the emails as they come in and figure out what went wrong. This is commonly done for mailing lists, and products like ListNanny are used to process the messages (it's a .NET product, but I'm sure there is a Java equivalent, or you could write it yourself).

The envelope "from" is different than the message "from" address. It's part of the SMTP conversation that happens between your code and your MTA. All NDRs will be sent to that address.

寻找一个思念的角度 2024-07-13 00:51:29

查找邮件服务器并连接:简单。 检查帐户:可以。 但这首先取决于您是否能够访问邮件服务器。 它可能会拒绝您的连接尝试(例如,因为您的网络已列入黑名单)

最复杂的事情就是您所说的“成功”:

简短的回答:否。

详细的回答:理论上这是可能的,但如果没有,您将不得不等待几个小时天才能知道状态。 通过灰名单、白名单、垃圾邮件拦截邮件服务器,许多服务器只会在多次尝试发送后才接受电子邮件。 只有当他们最终投递或放弃邮件时,您才会知道投递成功。 并且根据邮件服务器负载,电子邮件的发送可能会被推迟任意时间。

Finding the mail server and connecting: easy. Checking for an account: possible. But it depends on whether you get access to the mail server in the first place. It may decline your connection attempts (e.g. because your network is blacklisted)

The most complicated thing is what you call "success":

Short answer: No.

Long answer: Theoretically it would be possible, but you would have to wait for hours if not days to know the status. With graylisting, whitelisting, spam-blocking mail servers many will only accept an email after several delivery attempts. You will only know about delivery success when they have finally delivered or given up on the mail. And depending on mail server load the sending of an email may be postponed for an arbitrary amount of time.

〃温暖了心ぐ 2024-07-13 00:51:29

我对 Javamail 不太熟悉,但我想说:即使“成功”也可能不是成功。

您对硬故障和软故障的定义应该足够简单以便检查。 如果你找不到服务器,那就很难了,如果你连接上,服务器说“找不到邮箱”,那就是“软”。 但是,如果服务器接受消息然后又将其退回怎么办? 许多前端服务器根据设计或必要性接受未知消息(“真实”后端服务器的前端中继),并且如果稍后发现该消息被发送到无效地址,则该消息将被退回给发件人。 在这种情况下,您会报告发送“成功”,而实际上并未成功。

如果消息中没有嵌入某种“单击此处”,那么确保交付几乎是不可能的。

I'm not famliar specifically w/Javamail, but I would say this: Even "success" may not be success.

You're definition of hard and soft failures should be simple enough to check. If you can't find a server it's hard, if you connet and the server says "mailbox not found" it's "soft". But what if the server accepts the message and then bounces it later? Many front-end servers accept unknown messages, either by design or necessity (front end relay for "real" backend servers) and if the message is later found to be addressed to an invalid address the message is bounced back to the sender. In that case you'll have reported a "success" in sending when it's really not successful.

Ensuring delivery is next to impossible w/out some sort of "click here" embedded in the message.

乱了心跳 2024-07-13 00:51:29

不要依赖从服务器返回的(如果您返回)信息。

由于它造成的安全漏洞,许多邮件服务器现在设置为指示收件人是否存在。 (例如,如果给定的域正在报告(“是”/“否”)电子邮件地址的存在,则黑客只需在服务器上发起字典攻击即可确定所有有效用户,从而立即收到垃圾邮件列表。

Don't rely on what you get back (if you get back) info from a server.

Many mail servers are now set up to not indicate whether the receipient exists or not, due the the security hole it creates. (e.g. if a given domain is reporting ("yes"/"no") for the existence of an email address, a hacker would simply unleash a dictionary attack on the server to determine all the valid users, and thus they get an instant spam list.

风蛊 2024-07-13 00:51:29

您可以使用http://www.mailcounter.info免费服务检查是否您的电子邮件已被阅读以及该用户已阅读的次数。 这是一项免费服务。

You can use http://www.mailcounter.info free service to check whether your email has been read as well as how many times it has been read by t he user. Its a free service.

萌无敌 2024-07-13 00:51:29

您应该做的实际上是检查收件人电子邮件的 MX 记录(电子邮件地址的域部分的 DNS MX 查询)并通过已解析的 SMTP 服务器发送邮件。

这样,如果未找到 MX 记录,您将获得“硬退回”,如果找到但发送方法抛出异常,您将获得“软退回”,如果通过 - 您将获得“成功” ”。

您可以使用 dnsjava 项目来解析 MX 记录。
http://www.dnsjava.org/

what you should do is actually check the MX record of the recipient's email (DNS MX query of the domain portion of the email address) and send the message via the SMTP server that is resolved.

this way, if the MX record is not found, you get a "Hard Bounce", if it is found but the send method throws an exception, you get a "Soft Bounce", and if it goes through - you get a "Success".

you can use the dnsjava project to resolve the MX record.
http://www.dnsjava.org/

不必了 2024-07-13 00:51:29

这个 链接可能对您有帮助。 这是一个使用 RFC 3642 和 RFC 3464 的实验性 jar 文件。它有一些基本类,允许您获取邮件传递状态。 您还需要 Javamail jar 文件。

This link might helps you. This in an experimental jar file which uses RFC 3642 and RFC 3464. It has some basic classes which allows you to get the mail delivery status. And also you'll need Javamail jar file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文