0
votes

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".INTERNAL_ERROR message

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. My .eml imported to AMP playground
  • 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.

1
Can you try sending to another @gmail.com address this way? I suspect this issue is happening because you're sending the email to yourself.fstanis
@fstanis yeah, I've tried this. Another person also see HTML version only, but without error banner. Only clean HTML. When another person opens email source, the AMP content is stripped out - no AMP content or headers in message body at all. Developer settings in gmail client are turned on to allow dynamic emails from my address for another person as well.Tyutlaeva Ekaterina
In that case, I suspect the Gmail API simply doesn't support having a custom (in this case text/x-amp-html) mime type.fstanis
@TyutlaevaEkaterina I haven't tried sending using the gmail API, but I have no problem sending amp-emails using services like sendgrid and sparkpost. Maybe to avoid wasting time, try them?Alexandr Kazakov
@alexandr-kazakov Thank you so much! Sendgrid really works for me, I finally send my first AMP email and able to see it. Your comment is the most helpful!Tyutlaeva Ekaterina

1 Answers

-1
votes

If you are not yet registered with Google to send dynamic emails, you will not be able to.

For testing out AMP on Gmail you can use the Gmail AMP for Email playground which sends the dynamic email to your gmail inbox.


References: