内容を記載したメールをサイト管理者に送信する大きなフォームがあります。私が抱えている問題は、ある時点でスペースが挿入され、これがマークアップの問題を引き起こすことです。送信される電子メールはHTML電子メールであり、たとえばタグの間にラドムスペース文字が挿入されることがあるため、の代わりに。<li>
を取得し< li>
ます。これは問題です。これは、リストアイテムがリストアイテムとしてレンダリングされるのではなく、< li>
タグを含む通常のテキストとしてレンダリングされるためです。
私はこの振る舞いに少なくとももう1回気づきました。フォーラムに投稿したときに、入力した単語の途中にスペースが追加されました。不思議なことに、その言葉は法の母でした(スペイン語のスエグラ)。当時、私が最初に教えたのは、法律で母親の評判が悪かったために管理者が冗談を言ったということでしたが、今回は面白くありませんでした。今回は、マークアップがすべて台無しになるため、この問題は本当に問題です。
スペースが追加される理由を誰かが知っていますか?ランダムのようです。<
ただし、フォームのフィールドの1つから文字を削除すると、スペースが追加されていないように見えます。または、<とliの間ではなく、直前など、別の場所にスペースが追加されているため、マークアップ。また、メールで送信されるはずのメッセージをエコーするだけでは、メールで追加された場所の文字列にスペースがありません。
編集 ここに関連するコードがあります。かなり大きいですが、ほとんどは文字列を作成するだけです。
$subject = "New Quote Request";
$message = '<html><head></head><body>';
$message .= "<h1>New Quote Request.</h1>";
$message .= "<p>A new quote request has been submitted. Find all the submitted information bellow:</p>";
extract($_POST);
$message .= "<ul>";
$message .= "<li><strong>Company Name:</strong> $company</li>";
$message .= "<li><strong>Contact:</strong> $contact</li>";
$message .= "<li><strong>Email:</strong> $email</li>";
$message .= "<li><strong>Phone:</strong> $phone</li>";
$message .= "<li><strong>Alt. Phone:</strong> $cell</li>";
$message .= "<li><strong>Fax:</strong> $company_fax</li>";
$message .= "<li><strong>Address:</strong> $company_address</li>";
$message .= "<li><strong>City:</strong> $company_city</li>";
$message .= "<li><strong>State:</strong> $company_state</li>";
$message .= "<li><strong>Zip:</strong> $company_zip</li>";
$message .= "</ul>";
$message .= "<h2>Shipping Information</h2>";
$message .= "<li><strong>Mailing Address:</strong> $mailing</li>";
$message .= "<li><strong>City:</strong> $city</li>";
$message .= "<li><strong>State:</strong> $state</li>";
$message .= "<li><strong>Zip:</strong> $zip</li>";
$message .= "<h2>Project Infomration</h2>";
$message .= "<ul>";
$message .= "<li><strong>Project Name:</strong> $pname</li>";
$message .= "<li><strong>Due Date:</strong> $duedate</li>";
$message .= "</ul>";
$message .= "<h2>Project Specifications</h2>";
$message .= "<ul>";
$message .= "<li><strong>Quantities:</strong> $quantities</li>";
$message .= "<li><strong>Flat Size:</strong> $flat_size</li>";
$message .= "<li><strong>Finished Size:</strong> $finished_size</li>";
$message .= "<li><strong>Number of Pages:</strong> $num_of_pages</li>";
$message .= "<li><strong>Cover Options:</strong> </li>";//TODO self cover options
$message .= "</ul>";
$message .= "<h2>Cover</h2>";
$message .= "<ul>";
$message .= "<li><strong>Weight:</strong> {$cover['weight']}</li>";
$message .= "<li><strong>Color:</strong> {$cover['color']}</li>";
$message .= "<li><strong>Name:</strong> {$cover['name']}</li>";
$message .= "<li><strong>Finish:</strong> {$cover['finish']}</li>";
$message .= "</ul>";
$message .= "<h2>Text</h2>";
$message .= "<ul>";
$message .= "<li><strong>Weight:</strong> {$text['weight']}</li>";
$message .= "<li><strong>Color:</strong> {$text['color']}</li>";
$message .= "<li><strong>Name:</strong> {$text['name']}</li>";
$message .= "<li><strong>Finish:</strong> {$text['finish']}</li>";
$message .= "</ul>";
$message .= "<h2>Other</h2>";
$message .= "<ul>";
$message .= "<li><strong>Weight:</strong> {$other['weight']}</li>";
$message .= "<li><strong>Color:</strong> {$other['color']}</li>";
$message .= "<li><strong>Name:</strong> {$other['name']}</li>";
$message .= "<li><strong>Finish:</strong> {$other['finish']}</li>";
$message .= "</ul>";
$message .= "<h2>Coating</h2>";
$message .= "<ul>";
$message .= "<li><strong>Coating:</strong> {$coating['option']}</li>";
if(isset($coating['varnish']) && is_array($coating['varnish'])){
foreach($coating['varnish'] as $val){
$message .= "<li><strong></strong> $val</li>";
}
}
$message .= "<li><strong>Additional Information:</strong> {$coating['aditional']}</li>";
$message .= "</ul>";
$message .= "<h2>Cover</h2>";
$message .= "<ul>";
$message .= "<li><strong>Number of Colors:</strong> {$cover['num_of_colors']}</li>";
$message .= "<li><strong>PMS#:</strong> {$cover['pms']}</li>";
$message .= "<li><strong>Bleeds:</strong> {$cover['bleeds']}</li>";
$message .= "</ul>";
$message .= "<h2>Text</h2>";
$message .= "<ul>";
$message .= "<li><strong>Number of Colors:</strong> {$text['num_of_colors']}</li>";
$message .= "<li><strong>PMS#:</strong> {$text['pms']}</li>";
$message .= "<li><strong>Bleeds:</strong> {$text['bleeds']}</li>";
$message .= "</ul>";
$message .= "<h2>Other</h2>";
$message .= "<ul>";
$message .= "<li><strong>Number of Colors:</strong> {$other['num_of_colors']}</li>";
$message .= "<li><strong>PMS#:</strong> {$other['pms']}</li>";
$message .= "<li><strong>Bleeds:</strong> {$other['bleeds']}</li>";
$message .= "</ul>";
$message .= "<h2>Art</h2>";
$message .= "<ul>";
$message .= "<li><strong>Electronic Artwork Supplied:</strong> {$art['electronic_artwork_supplied']}</li>";
$message .= "<li><strong>Platform:</strong> {$art['platform']}</li>";
$message .= "<li><strong>Type of File:</strong> {$art['scans_required']}</li>";
if(isset($art['corrections']) && is_array($art['corrections'])){
foreach($art['corrections'] as $val){
$message .= "<li><strong>Corrections:</strong> {$val}</li>";
}
}
if(isset($art['design_needed'])){
$message .= "<li><strong>Design Needed:</strong> Yes</li>";
}
$message .= "</ul>";
$message .= "<h2>Bindery</h2>";
$message .= "<ul>";
if(isset($bindery) && is_array($bindery)){
foreach($bindery as $val){
$message .= "<li>$val</li>";
}
}
$message .= "<li><strong>Number of Drill Holes:</strong> {$bindery_['drill_holes']}</li>";
$message .= "<li><strong>Number of Pockets:</strong> {$bindery_['pockets']}</li>";
$message .= " <li><strong>Position: </strong> {$bindery_['position']}</li>";
$message .= "<li><strong>Size:</strong> {$bindery_['size']}</li>";
$message .= "<li><strong>Glue Pockets:</strong> {$bindery_['glue_pockets']}</li>";
$message .= "<li><strong>Business Cards Slits:</strong> {$bindery_['business_cards_slits']}</li>";
$message .= "</ul>";
$message .= "<h2>Packaging</h2>";
$message .= "<ul>";
if(isset($packaging['type']) && is_array($packaging['type'])){
foreach($packaging['type'] as $val){
$message .= "<li><strong>Type:</strong> {$val}</li>";
}
}
$message .= "<li><strong>Additional Instructions:</strong> {$packaging['aditional_shiping']}</li>";
$message .= "</ul>";
$message .= "<h2>Fullfillment</h2>";
$message .= "<ul>";
if(isset($fullfillment) && is_array($fullfillment)){
foreach($fullfillment as $val){
$message .= "<li>{$val}</li>";
}
}
$message .= "<li><strong>Fullfillment Requirements:</strong> " . nl2br($packaging['fullfillment_requirements']) . "</li>";
$message .= "</ul>";
$message .= "<h2>Mail Services</h2>";
$message .= "<ul>";
if(isset($mail_services['type']) && is_array($mail_services['type'])){
foreach($mail_services['type'] as $val){
$message .= "<li><strong>Type:</strong> {$val}</li>";
}
}
$message .= "<li><strong>Number of Inserts:</strong> {$mail_services['num_of_inserts']}</li>";
$message .= "<li><strong>Size of Outgoing:</strong> {$mail_services['size_of_outgoing']}</li>";
$message .= " </ul>";
$message .= "<h2>Shipping Instructions</h2>";
$message .= "<ul>";
if(isset($shipping_instructions['type']) && is_array($shipping_instructions['type'])){
foreach($shipping_instructions['type'] as $val){
$message .= "<li><strong>Type:</strong> {$val}</li>";
}
}
$message .= "<li><strong>Ship Via:</strong> {$shipping_instructions['ship_via']}</li>";
$message .= "<li><strong>FOB:</strong> {$shipping_instructions['fob']}</li>";
$message .= "</ul>";
$message .= "<h2>Additional Instructions</h2>";
$message .= "<p>" . nl2br($additional_instructions) . "</p>";
$message .= "</body></html>";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
global $request_quote_email;
mail($request_quote_email, $subject, $message, $headers);