I am trying to build a simple code to send Google AMP Emails using Magento 2. Can someone lead me in the right direction? There is no manual online even for PHP on how to do this. Thanks!
1 Answer
It all depends on your Magento version. If you are using Magento 2.3.x then you need to create class based on this interface: \Magento\Framework\Mail\MailMessageInterface
and rewrite this class - \Magento\Framework\Mail\Template\TransportBuilder
to add new AMP Mail Mime Part.
Your email body must have at least 2 MIME parts: HTML and AMP or TEXT and AMP. However it can include all three. Here is AMP Email example from AMP project: https://github.com/ampproject/amphtml/blob/master/spec/email/amp-email-structure.md
You can probably get some ideas from this python script to create AMP Emails: https://github.com/anirudhkhanna/AMP-Emails-via-Amazon-SES
Also, AMP Email extension for Magento 2 - https://store.plumrocket.com/amp-email-magento2-extension.html
Lastly, check this question on stackoverflow: https://stackoverflow.com/questions/22507176/send-html-and-plain-text-email-simultaneously-with-php-mailer/22507534
Hope it helps!