How to send an amp-HTML email with fallback plain and text email from amp gmail playground?

1.8k Views Asked by At

When I see the original mail it contains the amp HTML as well as plain and html text as well. when sent from the amp-playground it keeps default html and plain text values.

Is there any way to change the values of plain text and html texts?

2

There are 2 best solutions below

0
On

The Gmail playground is meant to be used to prototype and verify your AMP renders correctly in Gmail. It's not a generic email sending tool and doesn't let you modify the HTML or text part of the email.

1
On

AMP email is a multipart MIME message. It should have minimum HTML & AMP Html in the body. It is just an extension of a normal HTML email, which is a multipart MIME message.

So if you are asking how to create AMP HTML Email, then the step is to create two separate files. One just HTML Email & other for AMP HTML. Then depending on what code or language you are sending it should be sent in a multi-part message.

Refer this StackOverflow question to see how it's done when sending programmatically.

An example AMP Email will look like this:

From:  Person A <[email protected]>
To: Person B <[email protected]>
Subject: An AMP email!
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



Key points to keep in mind:

  1. Some email clients will only render the last MIME part. Place the text/x-amp-html MIME part before the text/html MIME part.
  2. An Html fallback content is compulsory as many clients don’t support AMP. Above that, the AMP part is removed when the email is forwarded.
  3. AMP email can only be sent from whitelisted email id. You can do that by following this documentation. https://developers.google.com/gmail/ampemail/register