Gmail Error :The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required

后端 未结 25 2461
悲&欢浪女
悲&欢浪女 2020-11-22 02:12

I am using following code to send email. The Code works correctly in my local Machine. But on Production server i am getting the error message

var fromAddres         


        
25条回答
  •  再見小時候
    2020-11-22 03:10

    Below is my code.I also had the same error but the problem was that i gave my password wrong.The below code will work perfectly..try it

                MailMessage mail = new MailMessage();
                SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");             
                mail.From = new MailAddress("fromaddress@gmail.com");
                mail.To.Add("toaddress1@gmail.com");
                mail.To.Add("toaddress2@gmail.com");
                mail.Subject = "Password Recovery ";
                mail.Body += " ";
                mail.Body += "";
                mail.Body += "";
                mail.Body += "";
                mail.Body += "";
                mail.Body += "";
    
                mail.Body += "";
                mail.Body += "";
                mail.Body += "";
                mail.Body += "
    User Name : HAi
    Password : aaaaaaaaaa
    "; mail.Body += ""; mail.Body += ""; mail.IsBodyHtml = true; SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential("sendfrommailaddress.com", "password"); SmtpServer.EnableSsl = true; SmtpServer.Send(mail);

    You can refer it in my blog

提交回复
热议问题