标签: amp-email

在 Ruby on Rails 中开发 AMP 电子邮件的问题

我正在尝试(但失败)使用 ActionMailer 配置 Ruby on Rails 应用程序以发送 AMP 电子邮件。现在正在寻找有关如何进一步调试的任何建议,我不知道还能做什么!

示例 AMP 模板在从AMP Gmail 游乐场发送时有效,但是当我从我们的 Rails 应用程序发送示例时,AMP 版本不会在 Gmail 中呈现。

config/initializers/mime_types.rb我补充说:

Mime::Type.register 'text/x-amp-html', :amp
Run Code Online (Sandbox Code Playgroud)

AMP 标记位于名为app/views/reminder_mailer/foo_notification.amp.erb. 为了测试,我的邮件程序方法如下所示:

def foo_notification
  mail(to: 'foo@example.com', subject: 'Foo subject') do |format|
    format.amp
    format.text
    format.html
  end
end
Run Code Online (Sandbox Code Playgroud)

我的 Rails 控制台的输出显示了正确发送的邮件,Content-Type: multipart/alternative后跟Content-Type: text/x-amp-html. 完整输出如下。

ReminderMailer#foo_notification: processed outbound mail in 19.9ms

Sent mail to foo@example.com (625.2ms)
Date: Thu, 06 Feb 2020 16:47:56 -0800
From: example <notifier@example.com>
Reply-To: example <notifier@example.com> …
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails actionmailer amp-html amp-email

6
推荐指数
1
解决办法
215
查看次数

AMP Email Playground 的正确 AMP-Access-Control-Allow-Source-Origin 响应标头是什么?

amp-email“安全要求”的文档指出:

如果它们有效,所有响应都必须回应上面的 origin 和 __amp_source_origin 值:

Access-Control-Allow-Origin: https://amp.gmail.dev
AMP-Access-Control-Allow-Source-Origin: amp@gmail.dev
Access-Control-Allow-Source-Origin: AMP-Access-Control-Allow-Source-Origin
Run Code Online (Sandbox Code Playgroud)

如果响应不包含这些值,则 CORS 请求将失败,从而导致浏览器控制台警告消息。

我正在操场上测试 amp-list 的使用,我的响应包含这些标头。但是,数据不会出现,并在控制台中我得到以下错误:Request xhr failed: The amp-access-control-allow-source-origin must be equal to the amp source origin sent in the request.???amp_source_origin请求中提供的amp@gmail.dev预期。

这是我返回的相关响应标头的副本:

Access-Control-Allow-Origin: https://amp.gmail.dev
Access-Control-Allow-Source-Origin: AMP-Access-Control-Allow-Source-Origin
Amp-Access-Control-Allow-Source-Origin: amp@gmail.dev
Run Code Online (Sandbox Code Playgroud)

我需要提供一些额外的标题吗?

cors amp-html amp-email

3
推荐指数
1
解决办法
744
查看次数

如何从Python发送AMP电子邮件?它在技术上与普通电子邮件有何不同

我试图了解什么是 AMP 电子邮件,并了解如何从 Pyhton/NodeJs/Ruby 等发送它。

目前在 Python 中我发送电子邮件如下:



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> …
Run Code Online (Sandbox Code Playgroud)

python email amp-email

2
推荐指数
1
解决办法
813
查看次数

标签 统计

amp-email ×3

amp-html ×2

actionmailer ×1

cors ×1

email ×1

python ×1

ruby ×1

ruby-on-rails ×1