How to attach an order PDF in an order confirmation email? I am currently adding a link to download the order PDF in the confirmation email with {{ order.getPdfUrl() }} but also want this to be an attachment.
You can send an email via your plugin's init() function like so:

craft()-&gt;on( 'email.onBeforeSendEmail', function( Event $event ){
    $email = $event-&gt;params['emailModel'];
    $attachment = array(
        'path'     =&gt; '/var/www/public/assets/downloads/filename.pdf',
        'name'     =&gt; 'File Title',
        'encoding' =&gt; 'base64',
        'type'     =&gt; 'application/pdf'
    );
    $email-&gt;addAttachment($attachment['path'], $attachment['name'], $attachment['encoding'], $attachment['type']);
});


Obviously, you'll want to do some checks on the Event and pass that off to a service to determine the logic for what should actually be attached.