通过Swiftmailer发送带回退的HTML邮件到纯文本邮件 [英] Send HTML mail with fallback to plain text mail via Swiftmailer
本文介绍了通过Swiftmailer发送带回退的HTML邮件到纯文本邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
在Swiftmailer中创建一条消息,您如何使用PHP Swiftmailer将回退的HTML邮件发送到纯文本邮件?并使用 setBody()
函数来设置邮件的文本/简单版本,并使用 addPart()
函数设置您的电子邮件的text / html版本(第二个参数 text / html
):
$ message = Swift_Message :: newInstance()
- > setSubject('您的主题')
- > setFrom(array('john@doe.com'=> 'John Doe')
- > setTo(array(beceiver@domain.org','other@domain.org'=>'A name'))
- > setBody '这是消息本身')
- > addPart('< p>这里是消息本身< / p>','text / html')
;
结帐资料来源: http://swiftmailer.org/docs/messages.html
How can you send HTML mail with a fallback to plain text mail with PHP Swiftmailer?
解决方案
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
):
$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
这篇关于通过Swiftmailer发送带回退的HTML邮件到纯文本邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文