Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
441 views
in Technique[技术] by (71.8m points)

html - Email markup-Gmail modifying the <script> tag to add extra string "3D"

I am using Ruby on Rails to generate the email. As mentioned in the Email markup docs, i modified my (*.html.haml) templates to include the schema for Email markup. Below code is from my mailer template:

%script{ type: "application/ld+json" }
  {
  "@context" : "http://schema.org",
  "@type" : "FoodEstablishmentReservation",
  "reservationNumber" : "#{reservation.id}",
  ...
  }

I also modified the sender and receiver of the email to the same email id as mentioned here for testing the schema in development mode.

When i receive the email in my Gmail inbox, and i don't see anything different from before. When i check the Original Message of the email, it shows:

Return-Path: <[email protected]>
...
Date: Wed, 21 Dec 2016 13:14:45 +0530
From: [email protected]
To: [email protected]
...
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="--==_mimepart_585a32ecf2d94_143673fd10d24128893014"; charset=UTF-8
Content-Transfer-Encoding: 7bit

----==_mimepart_585a32ecf2d94_143673fd10d24128893014
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
...
<script type=3D'application/ld+json'>
  {
  "@context" : "http://schema.org",
  "@type" : "FoodEstablishmentReservation",
  "reservationNumber" : "<reservation-id>",
  ...
  }
</script>
...

Now, if i validate this <script> tag content in the Email markup tester, it says "no structured data is present", but as soon as i remove "3D" from <script> tag and make it <script type='application/ld+json'>, it extracts the structured data correctly for all the fields.

So, i am unable to figure out why this extra string "3D" is being added to the HTML? Is it because of Haml? or Gmail does it? AND is there anything i can fix to test this Email markup in development environment. Let me know if more info is needed.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I had this same problem. It turns out I had a few misunderstandings which I will help clarify:

1) As pointed out above, the "Original Message" you saw in gmail was encoded as quoted-printable. You first have to decode the message, e.g. using Quoted Printable Converter, and the decoded message does not contain any 3Ds. The decoded message will then validate correctly (presumeably) using the Email Markup tester you referenced.

2) I arrived at this thread because I was debugging my integration using email markup. The markup wasn't showing in test emails and I thought I was implementing it incorrectly. I discovered my email schema integration must be whitelisted by Google to use these features.

I hope this helps.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...