Using the section header in Sendgrid

I am trying to send email through sendgrid in a Zend application. I am copying php code from sendgrid documentation (smtapi and swift class).

I am creating a template with places that should be replaced with% variable%. Now I am creating headers for sendgrid as defined here: http://docs.sendgrid.com/documentation/api/smtp-api/developers-guide/

As a result, I get something similar to 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 that all the data defined in the "sub" changes, I can not make the partition work. In the last letter I received% postername%. When I move this data to sub and repeat it for each letter, everything works fine.

Does anyone know what I'm doing wrong?

The documents for the section are here: http://docs.sendgrid.com/documentation/api/smtp-api/developers-guide/section-tags/

+5
source share
2 answers

Just FYI, SendGrid recently published a new PHP library. You can find it at http://github.com/sendgrid/sendgrid-php

(full disclosure: I am currently working in SendGrid, and my team developed a new library)

+1
source

I have found a solution. the section is used after substitution and does what sub does. Therefore, if I first wanted to use% postname% in all emails, I have to make sure that sub will place% postname% somewhere in the content.

+1
source

All Articles