【发布时间】:2016-12-01 19:37:28
【问题描述】:
我正在尝试将文件附加到电子邮件中。
首先我使用 snappyBundle 为 pdf 创建文件 && 使用 liugioBundle 的 xsl 文件。
之后我需要使用 swiftmailer 将其作为附件发送到电子邮件中。
有什么建议吗?
【问题讨论】:
标签: symfony pdf attachment xls swiftmailer
我正在尝试将文件附加到电子邮件中。
首先我使用 snappyBundle 为 pdf 创建文件 && 使用 liugioBundle 的 xsl 文件。
之后我需要使用 swiftmailer 将其作为附件发送到电子邮件中。
有什么建议吗?
【问题讨论】:
标签: symfony pdf attachment xls swiftmailer
你可以在你的 Switft_Mailer 对象上使用 ->attach() 方法
http://swiftmailer.org/docs/messages.html
$email = \Swift_Message::newInstance()
->setSubject('Subject')
->setFrom('me@domain.com')
->setTo($recipients)
->setBody(
$this->renderView(
'Emails/niceEmail.html.twig',
compact('foo', 'bar', 'message')
),
'text/html'
)
->attach(Swift_Attachment::fromPath('my-document.pdf'));
【讨论】: