Skip to content
Advertisement

What does this email from SendGrid is refering to in PHP API?

a few days a go we received a email from sendgrid stating they are going to change some behaviors in their API, I’ve done research but I have not found concretly what they are refering to, currently we are using the PHP API, and atleast for the 2) I think we are OK as we use SendGrid classes to build the emails

Check your code that uses the mail send endpoint and ensure that the “enable” parameter is included under the filter when applicable.

What do you need to do?

To avoid disruption to your mail send service, please be sure to make the following actions before August 10, 2021

  1. Check your code that uses the mail send endpoint and ensure that the “enable” parameter is included under the filter when applicable.

  2. Check your mail send header to ensure that you are using just one X-SMTPAPI header and address header of the same kind. Remove multiple headers of the same kind, so you have only 1 header of the same kind. For example, if you are currently using multiple “from” headers, you should modify your code so that you have a single “from” header.

  3. Check your code to ensure that you are not applying any personalization block substitution to your custom argument fields.

But what about the third item? we have substitions of following fashion: $mail->personalization[0]->addSubstitution('%url%', $link); But I havent found anything like a “block sustitution in custom arguments”

And the first item also worries me, I haven’t found anything like that neither, so I’m afraid that perhaps there is something that the PHP API does behind the scenes.

This a example of the code we use.

$sendgrid = new SendGrid(env('SENDGRID_APIKEY'));
$from_m = new SendGridEmail(null, $from);
$to_m = new SendGridEmail(null, $from);
$content = new SendGridContent("text/html", $body);
$mail = new SendGridMail($from_m, '.', $to_m, $content);
$mail->personalization[0]->addBcc($tos);
$mail->personalization[0]->setSubject($subject);
$mail->personalization[0]->addSubstitution('%MemberName%', $name);
$mail->personalization[0]->addSubstitution('%url%', $hash_url);
$mail->setTemplateId($template_id);
$sendgrid->client->mail()->send()->post($mail);

We are using sendgrid/sendgrid: ~6.2

Advertisement

Answer

Twilio SendGrid developer evangelist here.

From my reading of your code and the guidelines you’ve been sent, you should be ok.

  1. You don’t appear to be using anything that needs to be enabled via the API, though you can check all the mail_settings and tracking_settings in the API reference here.

  2. As you are using the library and calling the API you don’t appear to be sending any extra headers.

  3. You don’t seem to be using any custom arguments, so you aren’t applying any substitutions to them.

I do recommend that you upgrade your PHP helper library to version 7 from 6. That will ensure that the underlying library is also using the API in the most up to date manner.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement