'golang outlook smtp send mail

I have following code and it throws ""5.7.139 Authentication unsuccessful, the request did not meet the criteria to be authenticated successfully. Contact your administrator. [ZR0P278CA0110.CHEP278.PROD.OUTLOOK.COM]" error.

the code:

func main() {
    m := gomail.NewMessage()
    m.SetHeader("From", "****")
    m.SetHeader("To", "***")
    m.SetHeader("Subject", "Title")
    m.SetBody("text/html", "Message")
    d := gomail.NewDialer("smtp.office365.com", 587, "****", "****")
    d.TLSConfig = &tls.Config{InsecureSkipVerify: true}
    if err := d.DialAndSend(m); err != nil {
        fmt.Errorf(err.Error())
        //return err
    }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source