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 2259
悲&欢浪女
悲&欢浪女 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:00

    I tried all of the suggestions found here, from enabling less secure apps, to trying port 587... nothing worked. Finally I just commented out the line UseDefaultCredentials = false. Everything worked if I didn't touch that boolean.

    0 讨论(0)
  • 2020-11-22 03:01

    You might need to create/generate a specific APP password from gmail. you app or script will then use this new password instead of your regular password. Your regular password will still work fine for you.

    That is what did it for me. I still used the same email account but had to generate a new app specific password.

    https://support.google.com/accounts/answer/185833?hl=en

    Basically you can do it here: https://security.google.com/settings/security/apppasswords

    0 讨论(0)
  • 2020-11-22 03:01

    If your are using gmail.

    • 1-logon to your account

      2- browse this link

      3- Allow less secure apps: ON

    Enjoy....

    0 讨论(0)
  • 2020-11-22 03:04

    I have faced the same problem. It happens when you turn on 2 Step Verification (MFA). Just Turn off 2 Step Verification and your problem should be solved.

    0 讨论(0)
  • 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);
    }
    
    0 讨论(0)
  • 2020-11-22 03:05

    dont put break-point before await smtp.SendMailAsync(mail);

    :)

    when it waits with a break point giving this error when i remove break point it has worked

    0 讨论(0)
提交回复
热议问题