I am trying to send emails through sendgrid in Zend application. I copy the php code from the sendgrid documentation (smtapi class and swift).
I create a template with places that should be substituted with %variable%. Now I create headers for sendgrid as defined here: http://docs.sendgrid.com/documentation/api/smtp-api/developers-guide/
In result I get something looking like this:
{
"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"}
}
Now while all data defined in "sub" changes I cannot make section work. In the final email I still got %postername%. When I move this data to sub and repeat them for each email everything is working fine.
Has anyone a clue what I am doing wrong?
Docs for section are here: http://docs.sendgrid.com/documentation/api/smtp-api/developers-guide/section-tags/
Just FYI, SendGrid recently published a new PHP library. You can find it at http://github.com/sendgrid/sendgrid-php
(full disclosure: I currently work at SendGrid and my team developed the new library)
I found the solution. section is used after substitution and perform on what sub does. So if I wanted to use %postname% in all emails first I must make sure that sub will place %postname% somewhere in the content.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With