通过Swiftmailer发送回传到纯文本邮件的HTML邮件

时间:2015-03-30 11:55:02

标签: php email swiftmailer

如何使用PHP Swiftmailer发送回传到纯文本邮件的HTML邮件?

1 个答案:

答案 0 :(得分:0)

在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')
  ;

查看来源:http://swiftmailer.org/docs/messages.html

相关问题