简体   繁体   English

System.Net.Mail.SmtpException:邮箱不可用

[英]System.Net.Mail.SmtpException: Mailbox unavailable

// 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 = "contact@Server.com";
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)

5.7.1 == relaying prohibited 5.7.1 ==禁止中继

You need to allow relaying for authenticated users, or from a range of IPs from your SMTP server: http://support.microsoft.com/kb/304897 您需要允许中继经过身份验证的用户,或者从SMTP服务器的IP地址范围进行中继: http : //support.microsoft.com/kb/304897

What kind of server are you using to relay the messages? 您使用哪种服务器中继消息?

you have to set username in the SMTP Authentication as contact@Server.com . 您必须在SMTP身份验证中将用户名设置为contact@Server.com

        // CREATE NEW EMAIL OBJECT
        ContactUs.Core.Email oEmail = new ContactUs.Core.Email();

        // EMAIL SMTP SERVER INFORMATION
        oEmail.SmtpServer = "Server";
        oEmail.SetAuthentication("contact@Server.com", "Password");

        // EMAIL INFORMATION
        oEmail.From = "contact@Server.com";
        oEmail.To = "RecipientEmail";
        oEmail.Subject = this.txtMessage.Text;
        oEmail.Message = strMessage;

        // SEND EMAIL
        oEmail.HtmlFormat = true;
        oEmail.Send();

Your SMTP Server doesn't allow you to set Credential username different from oEmail.From (e-mail address of Sender). SMTP服务器不允许您设置与oEmail.From(发件人的电子邮件地址)不同的凭据用户名。

Add Network credentials to your code. 将网络凭据添加到您的代码。

Sample Mail Code: 样本邮件代码:

private void SendMailViaGmailUsingCredentials()
        {
            try
            {
                MailMessage mail = new MailMessage();
                SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");

                mail.From = new MailAddress("your_email_address@gmail.com");
                mail.To.Add("to_address@mfc.ae");
                mail.Subject = "Test Mail";
                mail.Body = "This is for testing SMTP mail from GMAIL";

                SmtpServer.Port = 587;
                SmtpServer.Credentials = new System.Net.NetworkCredential("username", "password");
                SmtpServer.EnableSsl = true;

                SmtpServer.Send(mail);
                MessageBox.Show("mail Send");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 出现错误:-System.net.mail.SmtpException - Getting error:-System.net.mail.SmtpException 如何修复 System.Net.Mail.SmtpException - How Can I Fix System.Net.Mail.SmtpException system.net.mail.smtpException:无法连接到远程服务器? - system.net.mail.smtpException :Unable to connect to the remote server? System.Net.Mail.SmtpException:该地址具有无效的主机名 - System.Net.Mail.SmtpException: The address has an invalid host name 如何正确处理System.Net.Mail.SmtpException? - How to correctly handle System.Net.Mail.SmtpException? System.Net.Mail.SmtpException {“发送电子邮件失败。”} - System.Net.Mail.SmtpException {“Failure Sending Email.”} System.Net.Mail.SmtpException:发送邮件失败。 无法从传输连接中读取数据 - System.Net.Mail.SmtpException: Failure sending mail. Unable to read data from the transport connection System.Net.Mail.SmtpException:系统存储不足。 服务器响应如下:4.3.1系统资源不足 - System.Net.Mail.SmtpException: Insufficient system storage. The server response was: 4.3.1 Insufficient system resources 将白名单IP gmail smtp-System.Net.Mail.SmtpException:发送邮件失败 - Whitelist IP gmail smtp - System.Net.Mail.SmtpException: Failure sending mail System.dll中发生了类型为'System.Net.Mail.SmtpException'的未处理的异常 - An unhandled exception of type 'System.Net.Mail.SmtpException' occurred in System.dll
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM