PHPMailer AltBody is not working
email, phpmailer, smtp
Solution
Because `msgHTML` overwrites `AltBody`. If you want to set `Body` and `AltBody` yourself, just set them. `msgHTML` is a convenience function to do several things for you, but you don't need to use it. If you want to use it but also set `AltBody`, just set it after you call `msgHTML`.
Problem
PHPMailer Version 5.2.7 ``` $mailerObject = new PHPMailer; $mailerObject->CharSet = 'UTF-8'; $mailerObject->IsSMTP(); $mailerObject->Host = 'dsfdf.sdfsdf.com'; $mailerObject->SMTPAuth = TRUE; $mailerObject->Username = 'dfgdfg'; $mailerObject->Password = 'dfgdfgdfg'; $mailerObject->SMTPSecure = 'tls'; $mailerObject->WordWrap = 60; $mailerObject->From = 'alex@test.de'; $mailerObject->FromName = 'test.de'; $mailerObject->AltBody = $bodyTextTemp; $mailerObject->MsgHTML($bodyHtmlTemp); ``` I am sending an HTML-Mail and an Text-Mail. In Thunderbird in HTML-Mode HTML is correctly shown. In Text-Mode you cant see the Text-Content ($bodyTextTemp), but the HTML-Content ($bodyHtmlTemp) where all HTML-Tags were removed (looks very ugly...). Looking to the Mail-source, I can see that the AltBody wasnt send. Why PHPMail dont accept my AltBody?