Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base64 Encoded PDF Fails #11

Open
matsolastrom opened this issue Aug 30, 2023 · 3 comments · May be fixed by #12
Open

Base64 Encoded PDF Fails #11

matsolastrom opened this issue Aug 30, 2023 · 3 comments · May be fixed by #12

Comments

@matsolastrom
Copy link

When using the SendSmtpEmailAttachment.php to send a PDF, sometimes the preg_match on line 266 fails without reason. Please remove this preg check or fix it. I am using a base_64 encoded PDF and it works fine to send it if I comment out the preg_match.

@mirsch
Copy link

mirsch commented Sep 11, 2023

reported this bug 5 years ago and still not fixed :(
sendinblue/APIv3-php-library#56

@StevenRenaux
Copy link

StevenRenaux commented Jun 20, 2024

I found a work around about this bug. I use this lib on Symfony app.
Not use SendSmtpEmailAttachment and add an array to the setAttachment() method.

Doesn't work

foreach ($email->getAttachments() as $file) {
    $sendSmtpEmailAttachment = (new SendSmtpEmailAttachment())
        ->setName($file->getFilename())
        ->setContent(base64_encode($file->getContent()));

    $attachments[] = $sendSmtpEmailAttachment;
}

$sendSmtpEmail->setAttachment($attachments);

Works like a charm

$attachments = [];
foreach ($email->getAttachments() as $file) {
    $attachments[] = [
        'name' => $file->getFilename(),
        'content' => base64_encode($file->getContent()),
    ];
}

$sendSmtpEmail->setAttachment($attachments);

Warning

You need to check what you receive before. Because you avoid that regex with that solution.

@DennisdeBest
Copy link

@StevenRenaux Thank you so much ! this fixed it for me !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants