System.Net.Mail.SmtpException:邮箱不可用
// CREATE NEW EMAIL OBJECT
ContactUs.Core.Email oEmail = new ContactUs.Core.Email();
// EMAIL SMTP SERVER INFORMATION
oEmail.SmtpServer = "Server";
oEmail.SetAuthentication("Email", "Password");
// EMAIL INFORMATION
oEmail.From = "[email protected]";
oEmail.To = "RecipientEmail";
oEmail.Subject = this.txtMessage.Text;
oEmail.Message = strMessage;
// SEND EMAIL
oEmail.HtmlFormat = true;
oEmail.Send();
这是我收到的错误。我知道认证是正确的。
System.Net.Mail.SmtpException: Mailbox unavailable. The server response was: 5.7.1 Client does not have permissions to send as this sender
at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response)
at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, String from)
at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at ContactUs.Core.Email.Send()
at _Default.btnSend_Click(Object sender, EventArgs e)
// CREATE NEW EMAIL OBJECT
ContactUs.Core.Email oEmail = new ContactUs.Core.Email();
// EMAIL SMTP SERVER INFORMATION
oEmail.SmtpServer = "Server";
oEmail.SetAuthentication("Email", "Password");
// EMAIL INFORMATION
oEmail.From = "[email protected]";
oEmail.To = "RecipientEmail";
oEmail.Subject = this.txtMessage.Text;
oEmail.Message = strMessage;
// SEND EMAIL
oEmail.HtmlFormat = true;
oEmail.Send();
This is the error I am getting. I know that the authentication is correct.
System.Net.Mail.SmtpException: Mailbox unavailable. The server response was: 5.7.1 Client does not have permissions to send as this sender
at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response)
at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, String from)
at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at ContactUs.Core.Email.Send()
at _Default.btnSend_Click(Object sender, EventArgs e)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
5.7.1 == 禁止中继
您需要允许经过身份验证的用户或来自 SMTP 服务器的一系列 IP 进行中继: http://support.microsoft.com/kb/304897
您使用什么类型的服务器来中继消息?
5.7.1 == relaying prohibited
You need to allow relaying for authenticated users, or from a range of IPs from your SMTP server: http://support.microsoft.com/kb/304897
What kind of server are you using to relay the messages?
您必须在 SMTP 身份验证中将用户名设置为 [email protected]。
您的 SMTP 服务器不允许您将凭据用户名设置为不同于 oEmail.From(发件人的电子邮件地址)。
you have to set username in the SMTP Authentication as [email protected].
Your SMTP Server doesn't allow you to set Credential username different from oEmail.From (e-mail address of Sender).
将网络凭据添加到您的代码中。
示例邮件代码:
Add Network credentials to your code.
Sample Mail Code: