php - Broken HTML-Mail because of space character -
php - Broken HTML-Mail because of space character -
here little snippet of php-code utilize create html e-mail:
$tmpl = '<table border="0" width="100%";><tr><td>%title%</td></tr><tr><td>%text%</td></tr></table>'; $html = '<table border="0" width="100%";>'; $html .= '<td width="20%" style="padding:0;">'; if(isset($var)) { $html .= 'value: '.$object->val; } $html .= '</td>'; $html .= '</table>'; $tmpl = str_replace('%text%', $html, $tmpl); $mail->setbody( $tmpl ); $mail->send();
sometimes mail service in html view when viewed within email programme broken because there space character within opening td-element. this:
< td width="20%" style="padding:0;">
where space character coming from?
had same issue php mail() function, html styling broken seemingly random spaces. using wordwrap() on message before sending mail service sorted out problem.
$message = wordwrap($message, 70); mail("person@example.com","some subject",$message);
www.w3schools.com explanation, example
php html email
Comments
Post a Comment