我有一个HTMl电子邮件模板,我想将其用于通过Heroku向人们发送自动电子邮件。我在Heroku上使用Sendgrid add on。
var html_content = "Thank you for registering to visit Philippine Property Show 2014 organised by"+
"PropertyGuru.This is the confirmation letter to your registration.Kindly present this letter at the registration counter for your entry to the event."
+"<br> <br>Thank you once again and see you at the event.<br><br>
<strong>Philippine Property Show</strong><br>
<strong>29 - 30 November 2013</strong><br>
<strong>Orchard Hotel, Level 2, Conference Centre<br>
</strong><br>"+"
<strong><span >With Warm Regards,</span></strong><span ><br>
<br>
</span><strong><span >PropertyGuru Events</span></strong><span ><br>
<br> ";
我在尝试使用上述变量的地方有下面的函数。
function send_mail_sendgrid(email_id){
sendgrid.send({
to: email_id,
from: '[email protected]',
fromname: 'PropertyGuru Events',
subject: 'Thank you for registering to visit Philippine Property Show 2014',
html: html_content;
}, function(err, json) {
if (err) { return console.error(err); }
console.log(json);
});
}
但是每次我运行此命令时,都会出现错误-
+"<br> <br>Thank you once again and see you at the event.<br><br>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Unexpected token ILLEGAL
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/bhagabanbehera/extra/pguru/app.js:7:14)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
显然,它无法识别我将HTML代码转储到js变量中的情况。我该如何做-通过带有模板的sendgrid发送电子邮件?
返回错误是因为您不能使用return破坏字符串html_content
。将变量更改为以下内容:
var html_content = "Thank you for registering to visit Philippine Property Show 2014 organised by "
+"PropertyGuru. This is the confirmation letter to your registration. Kindly present this letter at the registration counter for your entry to the event."
+"<br><br>Thank you once again and see you at the event.<br><br>"
+"<strong>Philippine Property Show</strong><br><strong>29 - 30 November 2013</strong>"
+"<br><strong>Orchard Hotel, Level 2, Conference Centre<br></strong><br>"
+"<strong><span>With Warm Regards,</span></strong><span><br><br></span>"
+"<strong><span>PropertyGuru Events</span></strong><span><br><br>";
另外,在sendgrid.send
其后删除分号后html: html_content
,它应该可以工作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句