title: Magento Send transactional email with PDF Attachment
body: <p>I have the following code, which appears to be sending transactional email (for a specific template id) via magento models.</p>
  
  <p>The only bit I can't get it to work is the attachment of PDF on the transactional email.</p>
  
  <p>This is the code I have so far:</p>
  
  <pre><code>function GetTransactionalSender() {
      return array(
          'name'  =&gt; Mage::getStoreConfig('trans_email/ident_support/name'),
          'email' =&gt; Mage::getStoreConfig('trans_email/ident_support/email')
      );
  }
  
  function SendTransactionalEmail($templateId, $recepientEmail, $recepientName, $vars, $storeId, $pdf_attachment = '') {
      $status = false;
      try {
          $transactionalEmail = Mage::getModel('core/email_template')
              -&gt;setDesignConfig(array('area' =&gt; 'frontend', 'store' =&gt; $storeId));;
          if (!empty($pdf_attachment) &amp;&amp; file_exists($pdf_attachment)) {
              $transactionalEmail
                  -&gt;getMail()
                  -&gt;createAttachment(file_get_contents($pdf_attachment), 'application/pdf')
                  -&gt;filename = basename($pdf_attachment);
          }
          $transactionalEmail
              -&gt;sendTransactional($templateId, GetTransactionalSender(), $recepientEmail, $recepientName, $vars);
          $status = true;
      } catch (Exception $e) { }
      return $status;
  }
  
  $template_id = 1;
  $to_email = 'user@domain.com';
  $to_name = 'User Name';
  $vars = array();
  $store_id = 1
  $pdf_file = '/full/path/to/my/file.pdf';
  $sent = SendTransactionalEmail($template_id, $to_email, $to_name, $vars, $store_id, $pdf_file);
  </code></pre>
  
  <p>When the email is sent, the attachment file name appears to be named : <strong>ATT00001.pdf</strong> and when you open it, it's a blank page.</p>
  
  <p>Any idea what I am doing wrong here? Do you attach a PDF onto a transactional email via Magento models?</p>