首页 > 解决方案 > 未找到 Swift Mailer Swift_Attachment 类

问题描述

我正在将 PDF 附加到电子邮件中,PDF 是通过 mPDF 生成的,并且生成得很完美。但是当我尝试使用 Swift Mailer 将其附加到电子邮件中时,它总是给我类错误Swift_Attachment class not found

代码

require __DIR__.'/swiftmailer/lib/classes/Swift.php';

$attachment = new Swift_Attachment($html, 'phpflow.pdf', 'application/pdf');

$message = Swift_Message::newInstance()
  ->setSubject('Here is the subject')
  ->setFrom(array('john@doe.com' => 'John Doe'))
  ->setTo(array('acb@gmail.com'))
  ->setBody('Here is the message itself')
  ->attach($attachment);

$transport = Swift_MailTransport::newInstance();
$mailer = Swift_Mailer::newInstance($transport);
$mailer->send($message);
$mpdf->Output($filename ,'I');

我不知道这里有什么问题,建议我

标签: phpswiftmailer

解决方案


推荐阅读