I want to send an email using Outlook servers, but I'm getting an error 504 5.7.4 Unrecognized authentication type
Here's the snippet.
func sendEmail() {
server := "smtp-mail.outlook.com
port := 587
user := "foo@outlook.com"
from := user
pass := "foobar"
dest := "bar@gmail.com"
auth := smtp.PlainAuth("", user, pass, server)
to := []string{dest}
msg := []byte("From: " + from + "
" +
"To: " + dest + "
" +
"Subject: Test outlook
" +
"OK")
endpoint := server + ":" + port
err := smtp.SendMail(endpoint, auth, from, to, msg)
if err != nil {
log.Fatal(err)
}
}
If instead of sending the email using outlook, I use gmail, it works fine.
In Python, I can send the email using outlook with the following code:
server = smtplib.SMTP(server, port)
server.starttls()
server.login(user, password)
server.sendmail(from, to, msg)
server.quit()
So I guess I'm missing something in my Go code. According to the doc, SendMail
switches to TLS
, so that shouldn't be the issue.