通过 POP3 自动检查退回的电子邮件?

发布于 2024-07-04 03:22:37 字数 1560 浏览 8 评论 0原文

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

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

发布评论

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

评论(5

谎言 2024-07-11 03:22:37

我在处理不同类型的退回邮件方面做了很多工作。 如果您想绝对确定您看到的电子邮件确实是某种特定类型的退回邮件,我强烈建议您使用一个好的过滤器。 我曾使用过 Boogie Tools,效果非常好。 它可以让您知道反弹的类型:硬跳动、软跳动、瞬态跳动,甚至是否有人试图取消订阅。 它有多个 API,包括 .Net,我发现它很容易上手。

I have done a great deal of work handling bounce emails and there different types. If you want to be absolutely sure that the email your looking at is indeed a bounce of a specific kind I highly recommend getting a good filter. I have worked with Boogie Tools and it has worked very well. It lets you know what kind of bounce it is, Hard, Soft, Transient or if its even someone trying to unsubscribe. It has a muliple API's including .Net and I found it quite easy to get working.

停顿的约定 2024-07-11 03:22:37

使用 TcpClient 可以很容易地做到这一点。 打开服务器:

TcpClient tcpClient = new TcpClient();
tcpClient.Connect(POP3Server, POP3Port);
NetworkStream stream = tcpClient.GetStream();

阅读欢迎消息:

int read = stream.Read(inBuffer, 0, inBuffer.Length);
string response = Encoding.ASCII.GetString(inBuffer, 0, read);
if (response.IndexOf("+OK") != 0) throw new ...;

写回服务器:

byte[] outBuffer = Encoding.ASCII.GetBytes("USER " + account + "\r\n");
stream.Write(outBuffer, 0, outBuffer.Length);

发送 USER 命令。 您需要登录,然后才能开始抓取邮件 - 请参阅 POP3 RFC 了解完整的命令列表。 如果您不想自己动手,请查看这篇 CodeProject 文章

It's pretty easy to do with a TcpClient. Open the server:

TcpClient tcpClient = new TcpClient();
tcpClient.Connect(POP3Server, POP3Port);
NetworkStream stream = tcpClient.GetStream();

Read the welcome message:

int read = stream.Read(inBuffer, 0, inBuffer.Length);
string response = Encoding.ASCII.GetString(inBuffer, 0, read);
if (response.IndexOf("+OK") != 0) throw new ...;

Write back to the server:

byte[] outBuffer = Encoding.ASCII.GetBytes("USER " + account + "\r\n");
stream.Write(outBuffer, 0, outBuffer.Length);

That sends the USER command. You need to login and then you can start grabbing messages - see the POP3 RFC for the full list of commands. If you're not looking to roll your own check out this CodeProject article.

jJeQQOZ5 2024-07-11 03:22:37

正如abfo所说,POP3协议非常简单,获取消息这是理所当然的。 解析消息以获取失败信息更加困难,并且可靠地解析出哪封电子邮件导致了失败以及失败的原因也非常困难。 问题是退回邮件没有标准格式,默认格式因 MTA 而异。 然后,站点管理员可以调整失败原因,使其更难以识别,并且站点管理员可以修改失败消息模板,这使得它几乎不可能。

看看是否可以找到 .NET 邮件列表管理器以及是否可以重新调整退回邮件处理代码的用途。 如果失败,请查看是否可以更改发送消息的工具,以从唯一的(且可逆的)信封发件人(VERP 我认为它被称为?)发送每封电子邮件。 这样您就不需要扫描电子邮件正文,您可以通过检查失败消息的收件人地址来判断哪个收件人失败了。

as abfo says, the POP3 protocol is super simple, getting the messages is a no brainer. Parsing the messages to get the failures is harder, and reliably parsing out which email caused the failure and why it failed is really hard. The problem is that bounce messages don't have a standard format, the default forms vary from MTA to MTA. Then the failure reason can be tweaked by the site admin making it harder to recognize, and the site admin could modify the failure message template which makes it darn near impossible.

See if you can find a .NET mailing list manager and if you can repurpose the bounce handling code. Failing that, see if you can change the tool that's sending the messages to send each email from a unique (and reversible) enveloper sender (VERP I think it's called?). That way you don't need to scan the body of the email, you can tell which recipient failed by examining the recipient address of the failure message.

旧人哭 2024-07-11 03:22:37

你的问题让我意识到我要使用的 WordPress Newsletter 插件没有退回邮件管理功能,而且我还需要一些东西。

我环顾了一段时间,最终选择了免费开源的 PHPlist 时事通讯管理器

他们详细描述了处理退回邮件的设置,并且他们确实有一个实验性的高级退回处理功能,允许您按照您想要的方式自定义退回处理。

即使您决定不使用 PHPlist,阅读他们的做法也会对您有用。

Your question made me realize that the Wordpress Newsletter plugin I was going to use, did not have bounce management, and I'd need something as well.

I looked around for awhile, and I've settled on the free and open-source PHPlist newsletter manager.

They describe in detail their settings for handling bounces and they do have an experimental advanced bounce handling feature that will allow you to customize the bounce handling exactly the way you want.

Evem if you decide not to use PHPlist, reading how they do it will be useful information for you.

韶华倾负 2024-07-11 03:22:37

感谢您的回答,太好了!
我自己做了一些研究,发现 ListNanny - 使用起来也超级简单,并告诉你反弹类型。 将写一些概念证明,看看我更喜欢哪一个......

Thanks for the answer, great!
I did some research myself and found ListNanny - also super simple to use and tells you the type of bounce. Will write some proof of concept and see which one I like better...

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