Delivery Notification in SMTP(SMTP 中的传递通知)
问题描述
下面的代码工作正常.但是,我需要将失败或成功通知发送到特定地址 (b@technospine.com).但是我收到了寄往 FromMail 地址(A@technospine.com)的送达通知邮件.你能帮我解决这个问题吗?
Below code is workin fine . However I need get Failure or Success Notification to Specific address (b@technospine.com). But I'm receiving Delivery Notification mail to FromMail address(A@technospine.com). Can you please help me to resolve this problem?
SmtpClient smtpClient = new SmtpClient();
MailMessage message = new MailMessage();
MailAddress fromAddress = new MailAddress("A@technospine.com", "BALA");
MailAddress adminAddress = new MailAddress("b@technospine.com");
smtpClient.Host = "Mail Server Name";
smtpClient.Port = 25;
smtpClient.UseDefaultCredentials = true;
message.From = fromAddress;
message.To.Add(_sendTo); //Recipent email
message.Subject = _subject;
message.Body = _details;
message.IsBodyHtml = true;
message.Headers.Add("Disposition-Notification-To", "b@technospine.com");
message.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess;
message.ReplyTo = adminAddress;
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.Send(message);
推荐答案
简短的回答是您所要求的不能以您假设的直接方式完成.
The short answer is what you are asking cannot be done in the direct manner in which you are assuming.
这仅在特定条件下有效.最容易描述的是,如果您用来发送消息的 SMTP 服务器与托管收件人电子邮件消息的域的服务器相同(您在设置 smtpClient 的 .HOST 属性时引用的服务器).因此,如果您只向本地 SMTP 邮件服务器上的收件人发送邮件,那么这可能会非常可靠.但这取决于正在使用的特定 SMTP 服务器软件,并且可能还取决于它的配置方式.
This will only work in certain conditions. The easiest to describe would be if the SMTP server you are using to send the message, is the same server that hosts the domain of the recipient email messages (the server you refer to when setting your .HOST property of smtpClient). So, if you were only sending to recipients on your local SMTP mail server, then this might work pretty reliably. But that depends on the specific SMTP server software being used and potentially also on how it is configured.
要解释为什么会这样,您必须意识到只有最后一个接收实际托管所需电子邮件地址的邮件的 SMTP 邮件服务器才能权威地回答这个问题,这是否是一个有效的电子邮件地址.如果消息在到达该最终权威服务器的途中必须通过任何其他电子邮件服务器,则必须将消息从一个服务器顺序传递到链中的下一个服务器,直到它到达该最终权威服务器.这意味着不存在用于验证特定地址的保证方法.再加上某些域被配置为充当黑洞并吞下非法地址的邮件这一事实,您可以看到有很多原因导致您不能依赖该方法.
To explain why this is, you must realize that only the last SMTP mail server receiving the message that actually hosts the desired email addresses, will be able to authoritatively answer the question, is this a valid email address. If the message has to pass through any other email servers on the way to getting at this final authoritative server, the message has to be handed off sequentially from one server to the next server in the chain until it reaches that final authoritative server. This means that there is not a guaranteed method for authenticating a specific address. Couple this with the fact that some domains are configured to act as a black hole and swallow illegitimately addressed mail, and you can see that there are many reasons why you cannot rely on that methodology.
因此,许多发往外部域的邮件都必须到达至少一个单独的 SMTP 服务器,并且取决于该服务器如何回答或转发邮件,它将决定任何特定接收域的结果.事实上,监控 FROM 地址中的退回邮件也不是万无一失的,正如我之前关于某些主机将某些邮件看起来无效时将其放入黑洞的评论一样.
So, many messages to external domains are going to have to hit at least one separate SMTP server and depending on how that server answers or forwards the mail, it will determine the results for any specific receiving domain. In fact, monitoring the FROM address for bounced messages is not foolproof either as my previous comment about some hosts putting some messages into a black hole if they do not appear to be valid.
这篇关于SMTP 中的传递通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:SMTP 中的传递通知
基础教程推荐
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 将 XML 转换为通用列表 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01