Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 30098

How to send AMP Email from Python? How is it technically different from Normal Email

$
0
0

I am trying to understand what is AMP Email and also understand how I can send it from something like Pyhton/NodeJs/Ruby.

Currently in Python I send email as below:



import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

from = "from@email.address"
to = "to@email.address"

msg = MIMEMultipart('alternative')
msg['Subject'] = "AMP Email"
msg['From'] = from
msg['To'] = to

#Email body.
plain_text = "Hi,\nThis is the plain text version of this Email.\nHere is a link that is for testing:\nhttps://amp.dev/documentation/guides-and-tutorials/start/create_email/?format=email"
html_amp = """\
<html amp4email>
  <head>
  <meta charset="utf-8">
  <script async src="https://cdn.ampproject.org/v0.js"></script>
  <style amp4email-boilerplate>body{visibility:hidden}</style>
  <style amp-custom>
    h1 {
      margin: 1rem;
    }
  </style>
</head>
  <body>
    <p>Hi!<br>
    <h1>Hello, I am an AMP EMAIL!</h1>
    </p>
  </body>
</html>
"""

part1 = MIMEText(plain_text, 'plain')
part2 = MIMEText(html_amp, 'html')

msg.attach(part1)
msg.attach(part2)

s = smtplib.SMTP('localhost')
s.sendmail(me, you, msg.as_string())
s.quit()

The above approach however isn't working.

I am trying to understand:

  1. What is the key advantage AMP brings to Email?
  2. How is it technically different?
  3. Can everyone send AMP Mail?
  4. Does it have any difference from normal emails?

Viewing all articles
Browse latest Browse all 30098

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>