在Sendgrid中使用节标题

5
我正在尝试在Zend应用程序中通过sendgrid发送电子邮件。我从sendgrid文档(smtpapi类和swift)中复制了PHP代码。
我创建了一个模板,并用%variable%替换了应该被替换的位置。现在,我按照此处定义的方式为sendgrid创建标题:http://docs.sendgrid.com/documentation/api/smtp-api/developers-guide/
结果看起来像这样:
{
"to": ["mail1@domain.com", "mail2@domain.com", "mail3@domain.com", "mail4@domain.com", "sfwwnkff@sharklasers.com"], 
"sub": {"%firstname%": ["Benny", "Chaim", "Ephraim", "Yehuda", "will"]}, 
"section": {"%postername%": "John Doe", "%postermail%": "james@doe.com", "%categoryname%": "General", "%threadname%": "Completely new thread", "%post%": "This thread is to inform you about something very important", "%threadurl%": "http:\/\/hb.local\/forums\/general\/thread\/143", "%replyto%": "http:\/\/hb.local\/forums\/general\/thread\/143", "%unsubscribeurl%": "http:\/\/hb.local\/forums\/settings\/", "%subscribeurl%": "http:\/\/hb.local\/forums\/subscribe-thread\/id\/143\/token\/1b20eb7799829e22ba2d48ca0867d3ce"}
}

现在当所有在“sub”中定义的数据发生变化时,我不能使部分起作用。在最终的电子邮件中,我仍然得到%postername%。当我将这些数据移动到“sub”并为每个电子邮件重复它们时,一切都正常工作。
有人知道我做错了什么吗?
部分的文档在这里:http://docs.sendgrid.com/documentation/api/smtp-api/developers-guide/section-tags/
2个回答

1

我找到了解决方案。在替换和执行 sub 的操作后,使用 section。因此,如果我想在所有电子邮件中使用 %postname%,首先必须确保 sub 将 %postname% 放置在内容的某个位置。


1

顺便提一下,SendGrid最近发布了一个新的PHP库。您可以在http://github.com/sendgrid/sendgrid-php找到它。

(完全透明:我目前在SendGrid工作,我的团队开发了这个新库)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接