php - Add category to send grid mail using web api -


i'm tracking send grid mail activities. want add category mail headers. code used:

$params = array(     'api_user'  => 'xxx',     'api_key'   => 'xxxx',     'to'        => $to,     'subject'   => $subject,     'html'      => $message,     'from'      => $from,     'category'  => 'news',    );  $request =  $url.'api/mail.send.json'; $session = curl_init($request); curl_setopt ($session, curlopt_post, true); curl_setopt ($session, curlopt_postfields, $params); curl_setopt($session, curlopt_header, false); curl_setopt($session, curlopt_returntransfer, true); $response = curl_exec($session); curl_close($session); 

but category (news) not added in send grid statistics. how can add category mail. please me.

you need pass categories json x-smtpapi param rather incuding @ top level. so:

$categories = array("category" => "news"); $params = array(   'api_user'  => 'xxx',   'api_key'   => 'xxxx',   'to'        => $to,   'subject'   => $subject,   'html'      => $message,   'from'      => $from,   'x-smtpapi'  => json_encode($categories)    ); 

you can see example of in practice in sendgrid documentation. additionally, here docs things can x-smtpapi headers, , have validator headers well.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -