SmtpClient.Credentials - 有什么用? [英] SmtpClient.Credentials - Whats the use?

查看:489
本文介绍了SmtpClient.Credentials - 有什么用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



我想发送电子邮件并收到送货单。我遇到了DeliveryNotificationOptions属性。现在一切正常,没有我使用网络凭据。



这会对接收邮件服务器发送回送收据有什么影响吗?



smtpclient的网络凭据是否仅用于某些smtp服务器,在允许发送电子邮件之前检查用户名,密码?





Hi everyone

I want to send an email and get a delivery receipt. I have come across the DeliveryNotificationOptions property. Now it all works fine without me using network credentials.

Will this have any effect on the receiver mail server sending the delivery receipts back?

Are the network credentials with the smtpclient only used on some smtp servers, which check for username,password before allowing the sending of emails?


MailMessage msg = new MailMessage();

msg.From = new MailAddress("xxxx@xxxx.com","xxxxxxxxxx");

msg.To.Add("xxx@xxx.com"); // Who's it to
msg.Subject = "Subject line";
msg.Body = "<html><h1>Big header</h1><p>And some smaller text</p></html>";
msg.IsBodyHtml = true;
        
// Delivery notifications
msg.DeliveryNotificationOptions =
DeliveryNotificationOptions.OnFailure |
DeliveryNotificationOptions.OnSuccess |
DeliveryNotificationOptions.Delay;


SmtpClient smtp = new SmtpClient("xxxxxxxxx");
// Using authentication to connect to above smtp server to send email.
// Replace txtSMTPUser and txtSMTPPass with your appropriate details.
/*System.Net.NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential("xxxx@xxxxx", "xxxxxxx");
smtp.UseDefaultCredentials = false;
smtp.Credentials = SMTPUserInfo;*/

smtp.Send(msg);

推荐答案

SMTP服务器的用户凭据与发送电子邮件时的身份验证无关。它确保没有适当凭据的人可以通过服务器发送电子邮件。



并且,这与交货收据无关。
User credentials for SMTP server serves no purpose more than to authenticate while sending an email. It ensures that noone with proper credentials could send an email via the server.

And, this has no relation to the delivery receipt.


如果服务器要求它登录,则需要它。
You need it if the server requires it to log in.


这篇关于SmtpClient.Credentials - 有什么用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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