我的 SMTP 服务器在发送大量电子邮件时出现了 100 多个错误。现在有很多 .BAD 文件,每个文件都包含一条错误消息,中间的某个地方是它应该发送到的实际电子邮件地址。
从每个文件中“仅”提取“电子邮件地址”的最简单方法是什么,以便我可以获得实际失败电子邮件的列表?
我可以用 C# 编写代码,任何建议都会受到欢迎。
错误的示例文本:
From: postmaster@my.server.com
To: me@me.com
Date: Tue, 25 Sep 2012 12:12:09 -0700
MIME-Version: 1.0
Content-Type: multipart/report; report-type=delivery-status;
boundary="9B095B5ADSN=_01CD9B35032DF58000000066my.server.co"
X-DSNContext: 7ce717b1 - 1386 - 00000002 - C00402D1
Message-ID: <FRaqbC8wS00000068@my.server.com>
Subject: Delivery Status Notification (Failure)
This is a MIME-formatted message.
Portions of this message may be unreadable without a MIME-capable mail program.
--9B095B5ADSN=_01CD9B35032DF58000000066my.server.co
Content-Type: text/plain; charset=unicode-1-1-utf-7
This is an automatically generated Delivery Status Notification.
Unable to deliver message to the following recipients, due to being unable to connect successfully to the destination mail server.
email@stackoverflow.com
--9B095B5ADSN=_01CD9B35032DF58000000066my.server.com
Content-Type: message/delivery-status
Reporting-MTA: dns;my.server.com
Received-From-MTA: dns;Social
Arrival-Date: Tue, 25 Sep 2012 11:45:15 -0700
Final-Recipient: rfc822;email@stackoverflow.com
Action: failed
Status: 4.4.7
--9B095B5ADSN=_01CD9B35032DF58000000066my.server.com
Content-Type: message/rfc822
Received: from Social ([127.0.0.1]) by my.server.com with Microsoft SMTPSVC(7.5.7601.17514);
Tue, 25 Sep 2012 11:45:15 -0700
主要是我想email@stackoverflow.com
在中间找到电子邮件。