Hi, i've been searching everywhere for the solutions to fix it but i still can't send email with pdf attachment.
$file_encoded = base64_encode(file_get_contents($attachment));
$email->addAttachment(
$file_encoded,
"application/pdf",
"another.pdf",
"attachment"
);
i'm using this code to attach pdf file but it's not working, please someone help, thank you
Hi @buddyy93,
Could you please send your attachment to [email protected] so that we can try and reproduce the error?
Thanks!
With Best Regards,
Elmer
Hi @buddyy93, it looks like your content get's base64 encoded twice. Just fiddling around with this library to add ICS invite as a attachment. I found out that the content gets encoded twice it it was already encoded, so this should work for you:
$file_encoded = file_get_contents($attachment);
$email->addAttachment(
$file_encoded,
"application/pdf",
"another.pdf",
"attachment"
);
@rcooo Thank you so much!

They might want to change that in their PHP examples..
Thanks for the heads up @nbarkat!
Since there has been no activity on this issue since March 1, 2020, we are closing this issue. Please feel free to reopen or create a new issue if you still require assistance. Thank you!
Most helpful comment
@rcooo Thank you so much!

They might want to change that in their PHP examples..