XF 2.0 Does the Email functionality in XF2 support attachments?

DragonByte Tech

Well-known member
Sorry for not having done research into this and asking blindly, but I figured it would be best to ask now so that if the answer is "No", I can add the Suggestion thread sooner rather than later :)

I'm going to want to automatically attach pre-generated PDF invoices to "Thank you for your purchase" emails.

Thanks!


Fillip
 
Not tested this, but we do expose a way to get the Swift_Message object, so it should be possible like this:
PHP:
$mail = $this->app()->mailer()->newMail()
    ->setToUser($user)
    ->setTemplate($template, $params);

$mail->getMessageObject()->attach(\Swift_Attachment::fromPath('path-to-file.pdf'));

$mail->queue();
 
Not tested this, but we do expose a way to get the Swift_Message object, so it should be possible like this:
Shiny, thanks :)

I've had a quick search through the code and I don't think XF or any of its vendor modules include a way to generate PDF from HTML. I'm not sure if you did this in your Xen Product Manager add-on - if you have any experience doing this, which library would you recommend?

I believe this is an old one I've used before, not really updated it for years though: https://github.com/dompdf/dompdf


Fillip
 

Similar threads

Back
Top Bottom