I want to send both HTML and Plain Text emails using wp_mail() function in wordpress
I wasn’t able to find a way to do that.
Does anyone know how to do that?
In PhpMailer for example there was an option to set both HTML and text with this line:
$mail->AltBody = $plain_text_format_mail;
Does anybody know if there is something similar for wp_mail that allow me to send both html as the main email and text as a fail safe option?
Thanks
2
Answers
use
Content-Type: text/html
for HTML email.use
Content-Type: text/plain
for plain email.I was also looking to send both plain text and html mail to get a better score on mail-tester.com
Hopefully I found this code snippet to add to you custom plugin, child-theme functions.php or even with the wp code snippet plugin:
This automatically associates a plain text version of your HTML email without modifying the common
wp_mail
function.eg:
And now mail-tester.com is happy with my email contents.