Cellpadding in HTML mail

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I'm trying to send a HTML mail using the mail() function in PHP. This is  
usually no problem. But now I'm trying to set a cellpadding value in the  
existing table. I've tried two ways in the message text:

$text .= "<table cellpadding=\"10\">";
$text .= "table cellpadding=".chr(34)."10".chr(34).">";

Cellpadding doesn't work and in the source code the above results in  
'<table cellpadding\=3D"10">.

What am I doing wrong?

   / Bo

Detta epostmeddelande innehåller inget virus eller annan skadlig kod fö
r avast! antivirus är aktivt.

Re: Cellpadding in HTML mail

Am 2014-08-22 09:57, schrieb Bo Wísén:

Quoted text here. Click to load it

"=3D" is the encoded version of "=" for quoted-printable encoding. Since
"=" has a special meaning in quoted-printable it has to be escaped by
using "=3D".

So - if your mail body is sent as quoted-printable, all is OK - just
make sure, the Content-Transfer-Encoding header also contains

Also see <https://www.ietf.org/rfc/rfc2045.txt and
<http://en.wikipedia.org/wiki/Quoted-printable .

Arno Welzel

Re: Cellpadding in HTML mail

Bo Wísén wrote:

Quoted text here. Click to load it

The above code alone cannot result in that.  The evaluated value of the  
right-hand side expression of the first alternative is equivalent to

  '<table cellpadding="10">'

when after “<?php” and before the optional “?>”.  This would be

  <table cellpadding=3D"10">
in the Quoted-Printable transfer-encoding that can be used in e-mail.  (3D  
is the hexadecimal code point and US-ASCII/ISO-8859-x/UTF-8 code sequence of  
the character “=” which, because it is special with QP, must be encoded  

Quoted text here. Click to load it

You are not posting the real code or not all the relevant code.

Your code is generally written too complicated.  You can write

  $text .= '<table cellpadding="10">';

to achieve the same.  You want to consider using implode() instead.

Your second posted alternative is, if not syntactically wrong, possibly  
ineffective: you have omitted the leading “<”.

If possible, do not send HTML e-mail.  If that is not possible, at least  
send a multi-part e-mail so that people who prefer not to have HTML in their  
e-mails can read the plain-text version.

For such e-mails you should use wrappers, not the mail() function directly.  
We have discussed this recently; please search before you post.

Quoted text here. Click to load it

Yours is not an e-mail eventually, so this pseudo-signature does not belong.  
It also makes no sense to those who do not understand the language in which  
it is written.  Please disable it.

You should avoid using this service because it is used mainly by trolls and  
spammers, and its appends this pseudo-signature to your postings.

Zend Certified PHP Engineer
Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

Site Timeline