• Resolved jarelsc

    (@jarelsc)


    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.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Shmetkov

    (@alexshmetkov)

    Mate, been trying to work out the issue for hours, shame your fix didn’t work for me. I Had to downgrade to 3.2.1

    FOR THE DEVELOPER:

    Adding an attachment file was breaking the form. Would send ok if I didn’t include file.

    Running latest WordPress on PHP 8

    WP Engine Error Log:

    ERROR PostmanWpMail: Exception code=0 message=Code: 400, Message: Bad Request, Body: {“errors”:[{“message”:”The attachment filename parameter is required.”,”field”:”attachments.0.filename”,”help”:”https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.attachments.filename”},{“message”:”The attachment filename parameter is required.”,”field”:”attachment

    ERROR PostmanWpMail: Exception code=0 message=Code: 400, Message: Bad Request, Body: {“errors”:[{“message”:”The attachment filename parameter is required.”,”field”:”attachments.0.filename”,”help”:”https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.attachments.filename”},{“message”:”The attachment filename parameter is required.”,”field”:”attachments.1.filename”,”help”:”https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.attachments.filename”}]}

    Thread Starter jarelsc

    (@jarelsc)

    I found the same issue later too. Looks like a PHP issue now. Since you’re getting an error I assume you’re on PHP8+. So instead of just adding to the array, I wrapped a conditional around it if the array is empty.

    $attachments = $this->addAttachmentToMail( $message );
    if( !empty( $attachments ) ) {
    $content[‘attachments’] = $attachments;
    }

    The above code got it working again for me with and without file attachments.

    **I’m not the plugin developer, and I edited the plugin file directly. So please proceed with caution.

    Plugin Support M Haseeb

    (@haseeb0001)

    Hi @jarelsc @alexshmetkov

    I hope you are doing well.

    We have fixed this issue on our Beta version; please download it from here, test it, and let me know.

    Thanks

    I can confirm that with this beta now works everything again and no crashes.

    Plugin Support M Haseeb

    (@haseeb0001)

    @mte90 Great, thanks for the update.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘SendGrid Files Fatal Error v2.4.1 and Fix’ is closed to new replies.