'Golang Send Mail via office365 smtp
I can send mail with my personal .hotmail email but when I try with my company mail address then the code throws an error. I used gomail package for implementation.
package main
import (
"crypto/tls"
"fmt"
gomail "gopkg.in/mail.v2"
)
func main() {
m := gomail.NewMessage()
m.SetHeader("From", "email")
m.SetHeader("To", "toemail")
m.SetHeader("Subject", "u.Title")
m.SetBody("text/html", "u.Message")
d := gomail.NewDialer("smtp.office365.com", 587, "email", "password")
d.TLSConfig = &tls.Config{InsecureSkipVerify: true}
if err := d.DialAndSend(m); err != nil {
fmt.Errorf(err.Error())
}
}
The code throws this error : "5.7.139 Authentication unsuccessful, SmtpClientAuthentication is disabled for the Tenant. Visit https://aka.ms/smtp_auth_disabled for more information. [ZR0P278CA0001.CHEP278.PROD.OUTLOOK.COM]"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
