ContentType === 'text/plain' ) { return; } // don't run if altbody is set (by other plugin) if( ! empty( $phpmailer->AltBody ) && $phpmailer->AltBody !== $this->previous_altbody ) { return; } // set AltBody $text_message = $this->strip_html_tags( $phpmailer->Body ); $phpmailer->AltBody = $text_message; $this->previous_altbody = $text_message; } /** * Remove HTML tags, including invisible text such as style and * script code, and embedded objects. Add line breaks around * block-level tags to prevent word joining after tag removal. */ private function strip_html_tags( $text ) { $text = preg_replace( array( // Remove invisible content '@]*?>.*?@siu', '@]*?>.*?@siu', '@]*?.*?@siu', '@]*?.*?@siu', '@]*?.*?@siu', '@]*?.*?@siu', '@]*?.*?@siu', '@\t+@siu', '@\n+@siu' ), '', $text ); // replace certain elements with a line-break $text = preg_replace( array( '@add_hooks();