How can you send HTML mail with a fallback to plain text mail with PHP Swiftmailer?
Send HTML mail with fallback to plain text mail via Swiftmailer
Asked Answered
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('[email protected]' => 'John Doe'))
->setTo(array('[email protected]', '[email protected]' => '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
© 2022 - 2024 — McMap. All rights reserved.