【问题标题】:Mailbox unavailable. The server response was: Please turn on SMTP Authentication in your mail client信箱不可用。服务器响应是:请在您的邮件客户端中打开 SMTP 身份验证
【发布时间】:2017-01-29 14:42:39
【问题描述】:

服务器响应是:请在您的邮件客户端中打开 SMTP 身份验证。

我正在使用其他服务器的 SMTP 详细信息,并且我的代码托管在其他服务器上。当我尝试发送邮件时,它给了我 SMTP Authentication 错误,如下所示:

邮箱不可用。服务器响应为:请在您的邮件客户端中打开 SMTP 身份验证。

System.Net.Mail.SmtpFailedRecipientsException:无法发送给所有人 收件人。 ---> System.Net.Mail.SmtpFailedRecipientException:邮箱 不可用。服务器响应是:请打开 SMTP 在您的邮件客户端中进行身份验证。

Here is my code:



public void SendIntimation()
            {
                try
                {
                    string strBody = MessageBody();
                    string strToEmail = txtEmail.Text.ToString();
                    string strBcc = "email@gmail.com";
                    MailMessage(strToEmail, strBcc, "Thank you for Register with us", strBody);
                }
                catch (Exception ex)
                {
                    Response.Write(ex);
                }
            }

        protected string MessageBody()
                {
                    string strBody = "Test 123";
                    return strbody();
                }
     public void MailMessage(string strMailTo, string strMailBcc, string strSubject, string strBody)
            {
        try
                {
                    MailMessage mailMsg = new MailMessage();
                    mailMsg.From = new MailAddress("sender@domain.com", "test");
                    mailMsg.To.Add(strMailTo);
                    //mailMsg.CC.Add(strMailCC);
                    mailMsg.Bcc.Add(strMailBcc);
                    mailMsg.Subject = strSubject;
                    mailMsg.Body = strBody;
                    mailMsg.Priority = MailPriority.Normal;
                    mailMsg.IsBodyHtml = true;
                    SmtpClient mailSmtp = new SmtpClient();
                    mailSmtp.Host = "domain.com";
                    mailSmtp.Port = 25;
                    mailSmtp.EnableSsl = true;
                    mailSmtp.Timeout = 90000;
                    mailSmtp.DeliveryMethod = SmtpDeliveryMethod.Network;
                    mailSmtp.UseDefaultCredentials = true;
                    NetworkCredential basicCredential = new 
                NetworkCredential("sender@domain.com", "password",
                "domain.com");                
                }
                catch (Exception ex)
                {
                    Response.Write(ex);
                }
    }

【问题讨论】:

  • UseDefaultCredentials 应该是 false 并且你需要 mailSmtp.Credentials = basicCredential;
  • 另外,您需要进入您的 Gmail 帐户,进入设置,并启用对您帐户的 POP3/SMTP 访问
  • 嗨@AlexK。这是一个拼写错误 UseDefaultCredentials 是假的。
  • @ShannonHolsinger,它不适用于 gmail,如果我输入任何其他邮件 ID,也会出现同样的错误。
  • 该错误告诉您服务器未获得外发 (smtp) 电子邮件的授权。端口 25 与 SSL 不一致。

标签: c# asp.net .net email smtp


【解决方案1】:

尝试基本方法并从那里开始:

   using System;
   using System.Windows.Forms;
   using System.Net.Mail;

   namespace WindowsApplication1
 {
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        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");
            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());
        }
    }
}
}

【讨论】:

    猜你喜欢
    • 2014-01-07
    • 1970-01-01
    • 1970-01-01
    • 2019-01-27
    • 2013-09-01
    • 1970-01-01
    相关资源
    最近更新 更多