XF 2.0 Does the Email functionality in XF2 support attachments?

DragonByte Tech

Well-known member
#1
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
 

Chris D

XenForo developer
Staff member
#2
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();
 

DragonByte Tech

Well-known member
#3
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
 
Top