Open matsolastrom opened 1 year ago
reported this bug 5 years ago and still not fixed :( https://github.com/sendinblue/APIv3-php-library/issues/56
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.
@StevenRenaux Thank you so much ! this fixed it for me !
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.