2016-07-27 79 views
-2

我想將文件附加到電子郵件。通過swiftmailer發送附加文檔

首先我使用snappyBundle爲pdf創建文件& &使用liugioBundle的xsl文件。

在此之後,我需要使用swiftmailer將它作爲電子郵件附件發送。

有什麼建議嗎?

回答

0

您可以只使用 - > attach()方法的Switft_Mailer對象

http://swiftmailer.org/docs/messages.html

$email = \Swift_Message::newInstance() 
    ->setSubject('Subject') 
    ->setFrom('[email protected]') 
    ->setTo($recipients) 
    ->setBody(
     $this->renderView(
      'Emails/niceEmail.html.twig', 
      compact('foo', 'bar', 'message') 
     ), 
     'text/html' 
    ) 
    ->attach(Swift_Attachment::fromPath('my-document.pdf'));