【发布时间】:2015-03-30 19:55:02
【问题描述】:
如何使用 PHP Swiftmailer 发送 HTML 邮件并退回到纯文本邮件?
【问题讨论】:
标签: php email swiftmailer
如何使用 PHP Swiftmailer 发送 HTML 邮件并退回到纯文本邮件?
【问题讨论】:
标签: php email swiftmailer
在 Swiftmailer 中创建消息并使用setBody() 函数设置邮件的文本/纯文本版本并使用addPart() 函数设置电子邮件的文本/html 版本(带有第二个参数text/html) :
$message = Swift_Message::newInstance()
->setSubject('Your subject')
->setFrom(array('john@doe.com' => 'John Doe'))
->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name'))
->setBody('Here is the message itself')
->addPart('<p>Here is the message itself</p>', 'text/html')
;
【讨论】: