我的要求是使用名为google card的节点模块通过电子邮件创建nodemailer。使用google developers我找到this。我创建了一个标记并使用google markup tester对其进行了验证。当我通过Gmail Actions发送邮件时,如我所提到的教程,我可以创建一个谷歌卡,但当我通过nodemailer发送电子邮件时,我无法创建我的Google卡。有人可以帮助解释为什么我无法通过nodemailer创建google now card
吗?
我的email
模板如下:
<html>
<head>
<script type="application/ld+json">
{ "@context": "http://schema.org",
"@type": "EventReservation",
"reservationNumber": "E123456789",
"reservationStatus": "http://schema.org/Confirmed",
"underName": {
"@type": "Person",
"name": "John Smith"
},
"reservationFor": {
"@type": "MusicEvent",
"name": "Foo Fighters Concert",
"url": "http://foofighterstour.com/SFO",
"performer": {
"@type": "Person",
"name": "The Foo Fighters",
"image": "http://www.amprocktv.com/wp-content/uploads/2013/01/foo-fighters-1-680x383.jpg"
},
"startDate": "2015-08-20T16:10:00+05:30",
"endDate": "2015-08-20T16:20:00+05:30",
"doorTime": "2015-08-20T16:01:00+05:30",
"location": {
"@type": "Place",
"name": "Random Park",
"address": {
"@type": "PostalAddress",
"streetAddress": "1 Random Street",
"addressLocality": "New Delhi",
"addressRegion": "Delhi",
"postalCode": "110001",
"addressCountry": "IN"
}
}
},
"ticketToken": "qrCode:AB34",
"ticketNumber": "abc123",
"numSeats": "1",
"modifiedTime" : "2015-08-20T16:05:00+05:30",
"modifyReservationUrl" : "http://www.google.com"}
</script>
</head>
<body>
<p>
This a test for an Event reservation Google Now card in Gmail.
</p>
</body>
</html>
Node JS中的Code
如下:
var fs = require('fs');
var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport("SMTP", {
service: 'Gmail',
auth: {
user: 'xyz@gmail.com',
pass: '123456'
}
});
fs.readFile('emailTemplatePath', "utf8", function (err, data) {
var mailOptions = {
from:'xyz@gmail.com' // sender address
to: 'xza@gmail.com', // list of receivers
subject: 'Booking reservation', // Subject line
html: data
};
transporter.sendMail(mailOptions);
});