From 2a67b397c744c632af62f87a933c0a8de36ae236 Mon Sep 17 00:00:00 2001 From: Nicola Murino Date: Mon, 29 May 2023 18:21:24 +0200 Subject: [PATCH] OAuth2: don't send the "*" command to cancel authentication XOAUTH2 does not follow the SMTP AUTH RFC --- smtp/smtp.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/smtp/smtp.go b/smtp/smtp.go index 316bcb2..a11aba4 100644 --- a/smtp/smtp.go +++ b/smtp/smtp.go @@ -234,8 +234,10 @@ func (c *Client) Auth(a Auth) error { resp, err = a.Next(msg, code == 334) } if err != nil { - // abort the AUTH - _, _, _ = c.cmd(501, "*") + if mech != "XOAUTH2" { + // abort the AUTH. Not required for XOAUTH2 + _, _, _ = c.cmd(501, "*") + } _ = c.Quit() break }