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 2403
悲&欢浪女
悲&欢浪女 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:04

    NOVEMBER 2018, have tried everything above with no success.

    Below is the solution that worked finally. Unfortunately it's not using SSL, but it works!!!

    var fromAddress = new MailAddress(asd@asd.com, "From Name");
    var toAddress = new MailAddress("tosend@asd.com", "To Name");
    
    const string subject = "Subject";
    const string body = "Body";
    
    var smtp = new SmtpClient
    {
        Host = "aspmx.l.google.com",
        Port = 25,
        EnableSsl = false
    };
    using (var message = new MailMessage(fromAddress, toAddress)
    {
        Subject = subject,
        Body = body
    })
    {
        smtp.Send(message);
    }
    

提交回复
热议问题