This Go program successfully sends email from my home computer, but on a virtual server on DigitalOcean receives the following error:
panic: 530 5.5.1 Authentication Required. Learn more at
Here's the code:
auth := smtp.PlainAuth("", "[email protected]", "PASSWORD", "smtp.gmail.com") msg := "Subject: Hello\r\n\r\nWorld!" e = smtp.SendMail("smtp.gmail.com:587", auth, "[email protected]", []string{email}, []byte(msg)) if e != nil { panic(e) }
There's two ways to solve this problem. Either configure your email client to use SMTP authentication. This setting is normally found in the account settings in your email client. Or, disable SMTP authentication for the IP range.
If getting "Username and Password not accepted" 535 5.7. 8 error, but user name and password work logging onto email via web (with 2-factor authentication), you may need to enable "Access for less secure apps" (allow exceptions to 2-factor authentication) in your email settings.
Get to your Gmail account's security settings and set permissions for "Less secure apps" to Enabled. Worked for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With