1

我有一个很大的表单,可以将包含其内容的电子邮件发送给站点管理员。我遇到的问题是在某些时候插入了一个空格,这会导致标记问题。发送的电子邮件是 HTML 电子邮件,有时会在标签之间插入随机空格字符,因此<li>我得到的不是< li>. 这是一个问题,因为列表项确实会被呈现为列表项,而是呈现为包含< li>标签的普通文本。

我至少有一次注意到这种行为。有一次,当我在论坛上发帖时,在我输入的单词中间添加了一个空格。奇怪的是,这个词是岳母,(西班牙语中的苏格拉)。当时很好笑,因为我第一次教的是,由于婆婆名声不好,管理员开了个玩笑,但这一次不好笑。这次这个问题真的是个问题,因为标记都搞砸了。

有谁知道为什么要添加空格?似乎是随机的。但是,如果我从表单上的一个字段中删除一个字符,则似乎没有添加空格,或者它可能是在不同的位置添加的,比如就在<< 和 li 之间而不是在 < 和 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);
4

1 回答 1

0

我认为最有可能的情况是线路由于太长而被打破。

尝试\n在其中插入一些,最好在每个之后插入<li>以保持合理的行长。

于 2012-09-24T19:13:25.350 回答