将 System.Net.Mail.MailMessage 替换为手动创建的消息并发送

发布于 2024-08-13 08:14:35 字数 1075 浏览 4 评论 0原文

我正在尝试发送将退回到已知邮箱的电子邮件。我打算使用VERP。不幸的是,System.Net.Mail.MailMessage 对象不允许我在电子邮件中精确设置 From: 和 Sender: 标头 - 它强制使用这些值,以便生成的电子邮件包含短语“代表”,并且不允许我可以很好地控制相关的 mime 标头。因此,我计划手动将 mime 电子邮件直接写入拾取目录,以便我可以独立控制发件人和发件人标头。我的开发盒是 Vista 盒,因此没有 SMTP 服务器。我想配置开发盒,以便在其上运行 SMTP 服务器。然后,我可以关闭 SMTP 服务器,将邮件写入取件目录,然后打开 SMPT 服务器并查看我编写的各个电子邮件的行为方式(有些已发送,有些退回到不同电子邮件域上的退回处理程序,按照发件人的指示)。两个问题: 1. 谁能推荐一个可以监控取件目录的 SMTP 服务器吗? 2.如果我按如下方式设置标题;来自:[电子邮件受保护];发件人:[电子邮件受保护] 然后收件人将看到电子邮件已发送来自 [email protected] (并且不会看到任何对 [电子邮件受保护]),但如果邮件被退回,则 NDR 将发送至[电子邮件受保护])。

必须这样做确实很痛苦,但我看不到任何使用 System.Net.Mail.MailMessage 而不弄乱我的标题的方法。

I am trying to send emails that will bounce to a known mailbox. I plan to use VERP. Unfortunately the System.Net.Mail.MailMessage object does not allow me to precisely set the From: and Sender: headers within my email - it forces the values so that the resulting email contains the phrase 'on behalf of', and does not allow me fine control over the relevant mime headers. I therefore plan to manually write mime email messages directly to the pickup directory so that I can independently control the From and Sender headers. My dev box is a Vista box and therefore does not have an SMTP server. I would like to configure the dev box so that I have an SMTP server running on it. I can then turn off the SMTP server, write messages to the pickup dir, then turn on the SMPT server and see how the individual emails that I have written will behave (some delivered, some bounced to a bounce handler on a different email domain, as dictated by the Sender). Two questions:
1. Can anyone recommend an SMTP server that will monitor a pickup directory?
2. If I set headers as follows; From:[email protected]; Sender:[email protected] then the recipient will see the email as having come from [email protected] ( and won't see any reference to [email protected]), but if the mail bounces then the NDR will be sent to [email protected]).

It's a real pain to have to do this, but I can't see any way of using System.Net.Mail.MailMessage without it messing up my headers.

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

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

发布评论

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

评论(1

不必了 2024-08-20 08:14:35

一个不错的(免费)SMTP 服务器是 Mercury - 它可以监视目录并且非常有用易于设置和配置。

A nice (free) SMTP server is Mercury - it can monitor a directory and is very simple to setup and configure.

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