SMTP 中的传递通知 [英] Delivery Notification in SMTP

查看:12
本文介绍了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 中的传递通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆