Search code examples
phpsymfony1swiftmailerjspdf

Sending Base64 PDF as email in symfony 2.8>


I have a PDF generated by jsPDF as a blob/base64 string, and I want to sent it to recipients through swiftmail without having to decode the string, create a PDF file and finnally attach it to the Mail.

My question is, Is their a way of attaching Bas64 to swiftmail and if it is possible will the recipient be able to see the file as a PDf using PDF viewers.


Solution

  • In order to attach a file to a SwiftMail you need to provide the content to Swift_Attachment::setBody() and it can NOT be base_64 (i already tried with images) or create the actual file in the filesystem and use Swift_Attachment::fromPath() so you will HAVE to decode you pdf anyways.

    SwiftMailer doc: http://swiftmailer.org/docs/messages.html#attaching-existing-files