Я пытаюсь отправить электронную почту с разметкой действия через учетную запись gmail с помощью электронной почты электронной почты django. Я могу успешно отправлять обычные электронные письма, но мне не повезло с разметкой по электронной почте.Email markup не работает с django send_email
Я следовал Google's quickstart, и это работает. Файл HTML является
<html>
<head>
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"description": "Check this out",
"potentialAction": {
"@type": "ViewAction",
"target": "https://www.youtube.com/watch?v=eH8KwfdkSqU",
"url": "https://www.youtube.com/watch?v=eH8KwfdkSqU"
}
}
</script>
</head>
<body>
<p>
This a test for a Go-To action in Gmail.
</p>
</body>
</html>
получил источник электронной почты выглядит следующим образом:
Subject: Test Email markup - Wed Dec 14 2016 20:00:41 GMT-0600 (CST)
From: <my gmail>@gmail.com
To: <my gmail>@gmail.com
Content-Type: multipart/alternative; boundary=94eb2c11658811d31e0543a8d263
--94eb2c11658811d31e0543a8d263
Content-Type: text/plain; charset=UTF-8; format=flowed; delsp=yes
This a test for a Go-To action in Gmail.
--94eb2c11658811d31e0543a8d263
Content-Type: text/html; charset=UTF-8
<html>
<head>
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"description": "Check this out",
"potentialAction": {
"@type": "ViewAction",
"target": "https://www.youtube.com/watch?v=eH8KwfdkSqU",
"url": "https://www.youtube.com/watch?v=eH8KwfdkSqU"
}
}
</script>
</head>
<body>
<p>
This a test for a Go-To action in Gmail.
</p>
</body>
</html>
--94eb2c11658811d31e0543a8d263--
Сейчас в Джанго, у меня есть
subject = "Test Subject"
from_email = 'Name <%s>' % settings.EMAIL_HOST_USER
to = '<my gmail>@gmail.com'
text_content = 'This is an important message.'
msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
msg.attach_alternative(render_to_string('email/test.html'), "text/html")
msg.send()
где test.html является файл шаблона, идентичный HTML Google, пример.
Принимаемый источник электронной почты для Джанго электронной почты выглядит следующим образом:
Content-Type: multipart/alternative; boundary="===============7033962557309231375=="
MIME-Version: 1.0
Subject: Test Subject
From: Name <gmail i'm sending [email protected]>
To: <my gmail>@gmail.com
Date: Thu, 15 Dec 2016 02:14:54 -0000
Message-ID: <[email protected]>
--===============7033962557309231375==
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
This is an important message.
--===============7033962557309231375==
MIME-Version: 1.0
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: 7bit
<html>
<head>
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"description": "Check this out",
"potentialAction": {
"@type": "ViewAction",
"target": "https://www.youtube.com/watch?v=eH8KwfdkSqU"
}
}
</script>
</head>
<body>
<p>
This a test for a Go-To action in Gmail.
</p>
</body>
</html>
--===============7033962557309231375==--
Основное различие я вижу кавычки вокруг кодирования и кодирования типа контента. Это корень проблемы, и если да, то как мне ее исправить?
Спасибо!