php - 未找到 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');
我不知道这里有什么问题,建议我
解决方案
推荐阅读
- sqlite - plum.sqlite 使用 sqlite 打开显示错误文件不是数据库
- r - R向现有的S4对象添加一个新槽
- google-cloud-platform - 无法通过 ssh 进入从 sourceImage“google_compute_instance_from_machine_image”创建的实例
- javascript - 使用 find 未定义嵌套对象
- visual-studio-code - 如果从远程管理器的命令行启动 VSCode 中的 EACCES 错误
- javascript - 如果执行未在给定时间内完成,Nodejs 将解决承诺
- api - XBee Pro S2C 中的数据类型和传输错误
- python - 在 Python 中水平打印图案
- python - /customer/2/ 'ReverseManyToOneDescriptor' 对象的 Django AttributeError 没有属性 'all'
- sql-server - 在存储过程、函数、视图或触发器中查找特定文本字符串