Sending HTML mail with return to regular text mail through Swiftmailer

How can you send backup HTML mail to plain text using PHP Swiftmailer?

0
source share
1 answer

Create a message in Swiftmailer and use the function setBody()to install the text / plain version of your email and use the function addPart()to install the text / html version of your email (with the 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 Source: http://swiftmailer.org/docs/messages.html

0
source

All Articles