I'm trying to send my first AMP email using gmail API from my gmail account to myself (To === From). I send exactly the same message as provided in the AMP documentation here: https://amp.dev/documentation/guides-and-tutorials/learn/email-spec/amp-email-structure/ , including all Content-Type headers for multipart/alternative message. But when I receive this message using my chrome gmail client I see only fallback HTML version and banner with error: "Why isn't the dynamic content rendered? There was an error displaying your dynamic email (INTERNAL_ERROR). More info".
Additional info:
- SPF, DKIM and DMARC are configured correctly, the status is PASS if I send email to somebody from my domain. My email service provider is google.
- Developer settings in gmail client is turned on: "Always allow dynamic emails from this sender: " .
- If I download this message from inbox as .eml and import it to AMP playground here: https://playground.amp.dev/?runtime=amp4email it imported successfully without validation errors. My email opens exactly as it should - as AMP hello world message.
I use gmail API to send message and js-base64 to encode it:
const gmail = google.gmail({ version: 'v1', auth: oauth2Client });
const base64EncodedEmail = Base64.encodeURI(email); const status = gmail.users.messages .send({ userId: mail_config.ADDRESS, uploadType: 'multipart', resource: { raw: base64EncodedEmail } })
The message itself (email variable from the code above) provided in the following code. exampleBody looks ugly, I've tried to use mimemessage npm package to generate it as well with the same INTERNAL_ERROR. Here is just example from AMP email documentation "as is": https://amp.dev/documentation/guides-and-tutorials/learn/email-spec/amp-email-structure/
const exampleBody = `Content-Type: multipart/alternative; boundary="001a114634ac3555ae05525685ae"
--001a114634ac3555ae05525685ae
Content-Type: text/plain; charset="UTF-8"; format=flowed; delsp=yes
Hello World in plain text!
--001a114634ac3555ae05525685ae
Content-Type: text/x-amp-html; charset="UTF-8"
<!doctype html>
<html ⚡4email>
<head>
<meta charset="utf-8">
<style amp4email-boilerplate>body{visibility:hidden}</style>
<script async src="https://cdn.ampproject.org/v0.js"></script>
</head>
<body>
Hello World in AMP!
</body>
</html>
--001a114634ac3555ae05525685ae
Content-Type: text/html; charset="UTF-8"
<span>Hello World in HTML!</span>
--001a114634ac3555ae05525685ae--`;
const email =
'From: ' +
my_address +
'\r\nTo: ' +
my_address +
'\r\nSubject: ' +
subject +
'\r\n' +
exampleBody;
What am I missing here? Please help.
text/x-amp-html
) mime type. – fstanis