Skip to content

Can we send without HTML #2945

Closed Answered by Synchro
ghost asked this question in Q&A
Aug 17, 2023 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

If you want to set plain-text only, that's the default behaviour, so it's very simple:

$mail->Body = 'my message body';

Body is a plain text body by default, but if you call isHTML, it will be handled as HTML, so this will produce an HTML-only message:

$mail->isHTML();
$mail->Body = '<b>my HTML message body</b>';

AltBody is there to provide a fallback to plain text, and typically you only set that if you are also using HTML:

$mail->isHTML();
$mail->Body = '<b>my HTML message body</b>';
$mail->AltBody = 'my plain text message body';

The msgHtml() method provides a shortcut and some automation to this process:

$mail->msgHtml('<b>my HTML message body</b>');

This will call isHTML, set Body

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
1 reply
@Synchro
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant