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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -