Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML-Email annoying line-breaking

Tags:

html

php

email

I'm digging deep in html-email stuff and finally, i have still an unsolved problem with annoying line-breaks :/

GMail and or Outlook are often breaking the line exactly during a tag - resulting in a completely broken look & feel.. so it can happen that the whole content is in a < h2 > because the ending-tag is broken through a line-break..

m</strong><br/>Passwort: <
strong>20o3a7

That's an example of a broken e-mail generated by my PHPMailer code..

Now i was fascinated with an email of a company, perfectly styled newsletter.. There i saw a code like this:

<table width=3D"100%" cellspacin=
g=3D"0" border=3D"0" cellpadding=3D"0">

This i can see on almost any line of this strange e-mail -> always ending with "=" on any line, altough if it is in the middle of a tag or a parameter-word.. and it is perfectly working! How that? It seems to me that this line-breaks are generated before it comes to the e-mail client, but this is only speculation of me...

I can find extermely nice articles how to create a correct HTML-Email like this:

http://24ways.org/2009/rock-solid-html-emails

But nobody writes something about this annoying line-break problem, but i can't believe that i'm the only one that has this issue... :/

like image 906
jebbie Avatar asked Aug 31 '12 13:08

jebbie


2 Answers

<table width=3D"100%" cellspacing=3D"0" border=3D"0" cellpadding=

It's called quoted printable encoding which is common for html emails. '=3D' for instance stands for '='.

Regarding to your problem: never occured to me. It's be difficult to debug without beeing able to look at the source. But it seems you got a solution anyway. :)

like image 143
lukeA Avatar answered Sep 24 '22 13:09

lukeA


Simple workaround

$body = str_replace("<","\r\n<", $body);

Every HTML tag will start from new line giving you:

m
</strong>
<br/>Passwort: 
<strong>20o3a7

Another thing is, i used PHPMailer in many projects, sending thousands e-mails to all mail clients, and i never experienced that issue. Make sure your code is OK. (maybe your text editor is wrapping that lines?)

like image 28
Peter Avatar answered Sep 21 '22 13:09

Peter