0

I am using Gmail API via PHP.

I am sending messages, and they bounce with:

"There was an error. Email was not sent."

But it does not mention the error.

How can I debug this situation?

I think the problem is in my message itself.

From: =?utf-8?B?VGF0aWFuYSBUb3JyZXMgTW9udGVybw==?= <...@gmail.com>
To: <...@gmail.com>
Subject: =?utf-8?B?TUlSQU1JUEVORQ==?=
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="_Part_150598468959c380b160a341.92104241"
--_Part_150598468959c380b160a341.92104241
Content-Type: multipart/alternative; boundary="_Part2_150598468959c380b160a514.30698822"
--_Part2_150598468959c380b160a514.30698822
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: base64
VHJhbmNhcyB5IGJhcnJhbmNhcyZyYXF1bzsgRW52aWFkbyBkZXNkZSBub21icmVBcHBhRGVjaWRpcg==
--_Part2_150598468959c380b160a514.30698822
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: base64
HDYd...
--_Part2_150598468959c380b160a514.30698822--
--_Part_150598468959c380b160a341.92104241
Content-Transfer-Encoding: base64
Content-Type: {image/jpeg}; name=una-imagen-adjunta.png;
Content-Disposition: attachment; filename=una-imagen-adjunta.png;
HGstdfwcy...
--

I tried Transfer-Encoding the text and html part with 7bit and 8bit too. But none of them is working, and I like more base64 so I stick with it for all parts.

Gmail API answer after sending:

object(Google_Service_Gmail_Message)#56 (14) { ["collection_key":protected]=> string(8) "labelIds" ["historyId"]=> NULL ["id"]=> string(16) "15ea3bd3e05c8509" ["internalDate"]=> NULL ["labelIds"]=> array(1) { [0]=> string(4) "SENT" } ["payloadType":protected]=> string(32) "Google_Service_Gmail_MessagePart" ["payloadDataType":protected]=> string(0) "" ["raw"]=> NULL ["sizeEstimate"]=> NULL ["snippet"]=> NULL ["threadId"]=> string(16) "15ea3bd3e05c8509" ["internal_gapi_mappings":protected]=> array(0) { } ["modelData":protected]=> array(0) { } ["processed":protected]=> array(0) { } }

Note: I can see the mail in the sent folder, with correct body and attached files.

enter image description here

And the bounce:

enter image description here

English: Email not sent. Error.

I do not know how to find the cause of this error, not even where to start.

Note: My API quota is alright, I do not use even 5% of daily quota.

Thank you.

Álvaro N. Franz
  • 1,188
  • 3
  • 17
  • 39
  • 1
    Have you built the message manually, or are you using a library for it? It might be that you don't have correct spacing between your part delimiters. Have you tried using blank lines like in [**this answer**](https://stackoverflow.com/questions/24908700/mail-attachment-wrong-media-type-gmail-api/24957873#24957873)? – Tholle Sep 21 '17 at 11:34
  • 1
    @Tholle The problem was, indeed, with spacing between parts. Thanks again sir Tholle. – Álvaro N. Franz Sep 21 '17 at 15:23
  • Great! No problem. – Tholle Sep 21 '17 at 15:31

0 Answers0