I'm trying to send a simple email via the Gmail API that's failing because of the RFC822-compliant To: undisclosed-recipients:;
header. Sending with a regular address in the To header works fine. The RFC822 message is created by PHPMailer and recovered using preSend()
and getSentMIMEMessage()
.
What am I doing wrong?
The message
Date: Tue, 21 Sep 2021 09:13:17 +0000
From: Rec1 <fictive1@gmail.com>
Cc: "Rec2 (fictive2@gmail.com)" <fictive2@gmail.com>
Bcc: fictive3@gmail.com
Message-ID: <vysFE9wLykAQc73VcxjiTfjPaZQJ5ge7jXqWbNeg@vps>
X-Mailer: PHPMailer 6.5.1 (https://github.com/PHPMailer/PHPMailer)
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="b1_vysFE9wLykAQc73VcxjiTfjPaZQJ5ge7jXqWbNeg"
Content-Transfer-Encoding: 8bit
To: undisclosed-recipients:;
Subject: test
This is a multi-part message in MIME format.
--b1_vysFE9wLykAQc73VcxjiTfjPaZQJ5ge7jXqWbNeg
Content-Type: text/plain; charset=us-ascii
body
--b1_vysFE9wLykAQc73VcxjiTfjPaZQJ5ge7jXqWbNeg
Content-Type: text/html; charset=us-ascii
<div dir="ltr">body</div>
--b1_vysFE9wLykAQc73VcxjiTfjPaZQJ5ge7jXqWbNeg--
The answer
{
"error": {
"code": 400,
"message": "Invalid To header",
"errors": [
{
"message": "Invalid To header",
"domain": "global",
"reason": "invalidArgument"
}
],
"status": "INVALID_ARGUMENT"
}
}