SendGrid Files Fatal Error v2.4.1 and Fix
-
As of your update, 2.4.1 using SendGrid’s endpoints, its throwing a Fatal Error here: /plugins/post-smtp/Postman/Postman-Mail/PostmanSendGridMailEngine.php, line 208. $email is now undefined. You have all other references in this file to this variable commented out. Looks like you missed updating this part of the code before pushing live. I didn’t have time to wait for a fix so I made it myself. Here’s the code updates:
Replace Lines 201-212 (You don’t need the foreach anymore since you have a function lower in the file.)
$attachments = $this->addAttachmentsToMail( $message );
foreach( $attachments as $index => $attachment ) {
$email->addAttachment(
$attachment[‘content’],
$attachment[‘type’],
$attachment[‘file_name’],
“attachment”
);
}
Replace with:
$content[‘attachments’] = $this->addAttachmentsToMail( $message );Then in your addAttachmentsToMail function in the $attachments[] array, replace key ‘id’ with ‘content_id’, replace key ‘file_name’ with ‘filename’, and add new key and value ‘name’ => $file_parts[0].
I found an example here https://github.com/sendgrid/sendgrid-php/blob/main/examples/mail/mail.php that shows the array keys for attachments.
Hope this helps. Great plugin.
- The topic ‘SendGrid Files Fatal Error v2.4.1 and Fix’ is closed to new replies.