私はHTML電子メールでテーブルをフォーマットするのに苦労しています。背景色や奇妙な空白を持たないセルが常にあるようです。
ここにコードがあります(PHPで) -
$subject.="
New & Used Vehicles Term in Months APR* As Low As Monthly Payment Per $1000 Borrowed ";
$result = mysql_query("SELECT * FROM rates WHERE ID>='32' AND ID <='39'");
while($row = mysql_fetch_array($result))
{
$subject.= "" . $row['name'] . " ";
$subject.= "" . $row['term'] . " ";
$subject.= "" . $row['apr'] . " ";
$subject.= "" . $row['per_1000'] . " ";
}
$subject.= "
";
だから私は両方のCSSの背景とhtmlを試してみました。私はDoctypesも試みました。
これは私のメールコードの外観です。
mail( "[email protected]", "$title2", "$subject" , "Content-type: text/html;\r\nFrom: [email protected]" );
ここでそれはどのようにレンダリングされます。不正な空間を参照してください?
Check out the low rates.New & Used Vehicles Term in Months APR* As Low As Monthly Payment Per $1000 Borrowed 2008 and NEWER Vehicle Purchases Up to 72 Months 3.24% $17.28 2008 and NEWER Vehicle!
Purchases 64 - 72 Months 4.29% $15.69 2007 and OLDER Vehicle Purchases Up to 72 Months 5.49% $18.20 2007 and OLDER Vehicle Purchases 64 - 72 Months 5.99% $16.46 2011 & 2010 REFINANCES Up to 63 Months 4.99% $18.08 2011 & 2010 REFINANCES 64 - 72 Months 5.49% $16.34 2008 - 2009 REFINANCES Up to 60 Months 5.99% $19.33 2007 & older Vehicle REFINANCE Up to 60 Months 6.99% $19.80
私自身の質問に答えるのは嫌いですが、私は問題の解決策を見つけました。誰かがこの解決策を使って頭痛を取り除くことができれば幸いです。
The issue is being caused by use of the mail() function. When I try to send the email, I have a long string of html code. IN FACT, TOO LONG! When I go past 78 characters a BANG! shows up and then jacks with my html or css. RFC 2822
解決策は、データをベース64にエンコードするか、長い行のhtmlコードに\ r \ nを追加することです。いずれの方法でも問題が解決されます。
誰も助けてくれてありがとう!
Base64エンコードされた電子メールを作成する方法の例を次に示します。
<?php
$html = "The quick brown fox jumped right over the lazy dog.
";
$to = "[email protected]";
$cc = "[email protected]";
$bcc = "[email protected]";
$from = "[email protected]";
$subject = "This is a MIME encoded email";
$boundary = str_replace(" ", "", date('l jS \of F Y h i s A'));
$newline = "\r\n";
$headers = "From: $from$newline".
"Cc: $cc$newline".
"Bcc: $bcc$newline".
"MIME-Version: 1.0$newline".
"Content-Type: multipart/alternative;".
"boundary = \"$boundary\"$newline$newline".
"--$boundary$newline".
"Content-Type: text/html; charset=ISO-8859-1$newline".
"Content-Transfer-Encoding: base64$newline$newline";
$headers .= rtrim(chunk_split(base64_encode($html)));
mail($to,$subject,"",$headers);
?>
このコードは次のサイトで見つかりました:
https://ctrlq.org/code/19840-base64-encoded-email
電子メールをBased64 Encodedに設定すると、ランダムな '!'電子メールに追加されます。