5

我正在尝试通过 Zend 应用程序中的 sendgrid 发送电子邮件。我从 sendgrid 文档(smtapi 类和 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"}
}

现在,虽然“子”中定义的所有数据都发生了变化,但我无法使部分工作。在最后一封电子邮件中,我仍然收到 %postername%。当我将这些数据移动到 sub 并为每封电子邮件重复它们时,一切正常。

有谁知道我做错了什么?

部分的文档在这里:http ://docs.sendgrid.com/documentation/api/smtp-api/developers-guide/section-tags/

4

2 回答 2

1

仅供参考,SendGrid 最近发布了一个新的 PHP 库。您可以在http://github.com/sendgrid/sendgrid-php找到它

(全面披露:我目前在 SendGrid 工作,我的团队开发了新库)

于 2012-03-27T03:37:57.673 回答
1

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

于 2012-09-27T23:49:52.350 回答