How can you send HTML mail with a fallback to plain text mail with PHP Swiftmailer?
如何使用PHP Swiftmailer发送带有回退到纯文本邮件的HTML邮件?
1 个解决方案
#1
0
Create a message in Swiftmailer and use the setBody()
function to set the text/plain version of your mail and use the addPart()
function to set the text/html version of your email (with second parameter text/html
):
在Swiftmailer中创建一条消息,并使用setBody()函数设置邮件的文本/纯文本版本,并使用addPart()函数设置电子邮件的text / 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')
;
Checkout the source: http://swiftmailer.org/docs/messages.html
查看来源:http://swiftmailer.org/docs/messages.html
#1
0
Create a message in Swiftmailer and use the setBody()
function to set the text/plain version of your mail and use the addPart()
function to set the text/html version of your email (with second parameter text/html
):
在Swiftmailer中创建一条消息,并使用setBody()函数设置邮件的文本/纯文本版本,并使用addPart()函数设置电子邮件的text / 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')
;
Checkout the source: http://swiftmailer.org/docs/messages.html
查看来源:http://swiftmailer.org/docs/messages.html