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

本文关键字:客户端 身份验证 SMTP 服务器 响应 | 更新日期: 2023-09-27 18:08:09

服务器响应为:请在邮件客户端打开SMTP身份验证

我正在使用其他服务器的SMTP详细信息,我的代码托管在其他服务器上。当我试图发送邮件时,它会给我错误的SMTP身份验证如下所示:

邮箱不可用。服务器的响应是:请在您的邮件客户端中打开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);
                }
    }

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

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

   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());
        }
    }
}
}