在godaddy中邮件发送代码错误



我用我的一个word press项目创建了一个邮件发送脚本,并在我自己的服务器上很好地测试了它,它工作并获得包括附件在内的所有邮件内容,后来我将项目转移到godaddy服务器,错误是Array ([type] => 2 [message] => mail():在additional_header

中发现多个或错误的换行符

$strHeader .= "Content-Type: multipart/mixed; boundary="".$strSid.""nn";

我需要解决方案,事实上我是PHP新手,这是我在堆栈中的第一篇文章,请帮助我有一个解决方案

我将代码附加到这个

<?php //Template Name: Page app handle ?>
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
$(window).load(function () {
  // Page is fully loaded .. time to fade out your div with a timer ..
   $('#overlay img').fadeOut(5000);
   });
   </script>

   <?php 
  if(!isset($_POST['fname']))
  {
echo "<script>window.location.href = '".   `  `     get_site_url()."/index.php/application/</script>";
}
$ar_modltype = $_POST['model_type'];
$cntmodel = count($ar_modltype);
if($cntmodel>0)
{
for($j=0;$j<$cntmodel;$j++)
{
$modltype = $modltype.", ".$ar_modltype[$j];
}
 }
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$gender = $_POST['gender'];
$dob = $_POST['dob'];
$nationality = $_POST['nationality'];
$mobile = $_POST['mobile'];
$email = $_POST['email'];
$location = $_POST['location'];
$selvissa = $_POST['selvissa'];
$ethnicity = $_POST['ethnicity'];
$height = $_POST['height'];
$hips = $_POST['hips'];
$hair_color1 = $_POST['hair_color'];
if($hair_color1=="Other")
{
$hair_color=$_POST['s_hair_color'];
}
else
{
 $hair_color=$hair_color1;
 }
$chest = $_POST['chest'];
$shoe = $_POST['shoe'];
$eye_color = $_POST['eye_color'];
$waist = $_POST['waist'];
$hair = $_POST['hair'];
/*if (isset($_POST['health_card'])) {
  $healthcard="Yes";
 }
 else
 {
$healthcard="No";
 }*/

if (isset($_POST['driving_license'])) {
 $driving_license="Yes";
}
else
{
    $driving_license="No";
 }
if (isset($_POST['portfolio'])) {
   $portfolio="Yes";
  }
else
 {
$portfolio="No";
 }
 /*if (isset($_POST['duty_free'])) {
$duty_free="Yes";
 }
 else
{
$duty_free="No";
 }*/
 $ar_availability = $_POST['availability'];
 $cntavail = count($ar_availability);
 if($cntavail>0)
 {
for($i=0;$i<$cntavail;$i++)
{
$availability = $availability.", ".$ar_availability[$i];
}
 }
   $langhid = $_POST['langhid'];
$experience = $_POST['experience'];
//$prvs_events = $_POST['prvs_events'];
$avg_pay = $_POST['avg_pay'];
$remarks = $_POST['remarks'];

   $modltype1 = str_replace(',', '/', $modltype);
//mailing
   $loop = new WP_Query(array('post_type'=>'mainpoint_news','orderby'=>'id','order'=>'asc','posts_per_page' => 1));
    if ($loop->have_posts()){


        $x=1;

        while($loop->have_posts()){
        $loop->the_post();
      $meta=  get_post_custom(get_the_ID());   
       $strTo= esc_attr($meta['mainpoint_newsarea'][0]);
     // $to="abu"; 
      //echo $to;
       //exit();
}}

    $strSubject = substr($modltype1,1).":".$fname;
    //$strMessage = $msg;
    //*** Uniqid Session ***//
    $strSid = md5(uniqid(time()));
    $strHeader = "";
    $strHeader .= "From:".trim($fname)."<".$email.">nReply-To:".$email."";
    $strHeader .= "MIME-Version: 1.0n";
    $strHeader .= "Content-Type: multipart/mixed; boundary="".$strSid.""nn";
    $strHeader .= "This is a multi-part message in MIME format.n";
    $strHeader .= "--".$strSid."n";
    $strHeader .= "Content-type: text/html; charset=utf-8n";
    $strHeader .= "Content-Transfer-Encoding: 7bitnn";
    $strHeader .= "<h1>Contact Details</h1>n";
        $strHeader .= "<label style='font-size:17px'><b>Categories : </b></label><label style='font-size:16px'><b>".substr($modltype,1)."</b></label><br>";        
        $strHeader .= "<label style='font-size:17px'><b>First Name : </b></label><label style='font-size:16px'><b>".$fname ."</b></label><br>";
        $strHeader .= "<label style='font-size:17px'><b>Last Name : </b></label><label style='font-size:16px'><b>".$lname ."</b></label><br>";
        $strHeader .= "<label style='font-size:17px'><b>Gender : </b></label><label style='font-size:16px'><b>".$gender."</b></label><br>";
        $strHeader .= "<label style='font-size:17px'><b>Date of Birth : </b></label><label style='font-size:16px'><b>".$dob ."</b></label><br>";
        $strHeader .= "<label style='font-size:17px'><b>Nationality : </b></label><label style='font-size:16px'><b>".$nationality ."</b></label><br>";
        $strHeader .= "<label style='font-size:17px'><b>Mobile  : </b></label><label style='font-size:16px'><b>".$mobile ."</b></label><br>";
        $strHeader .= "<label style='font-size:17px'><b>Email  :  </b></label><label style='font-size:16px'><b>".$email ."</b></label><br>";
        $strHeader .= "<label style='font-size:17px'><b>Location  :  </b></label><label style='font-size:16px'><b>".$location ."</b></label><br>";
        $strHeader .= "<label style='font-size:17px'><b>Visa Type :  </b></label><label style='font-size:16px'><b>".$selvissa ."</b></label><br>";        
         $strHeader .= "<h1>Personal Details</h1>";
        $strHeader .= "<label style='font-size:17px'><b>Ethnicity  : </b></label><label style='font-size:16px'><b>".$ethnicity ."</b></label><br>";
        $strHeader .= "<label style='font-size:17px'><b>Height  : </b></label><label style='font-size:16px'><b>".$height ."</b></label><br>";
        $strHeader .= "<label style='font-size:17px'><b>Hips  : </b></label><label style='font-size:16px'><b>".$hips ."</b></label><br>";
        $strHeader .= "<label style='font-size:17px'><b>Hair Color  :  </b></label><label style='font-size:16px'><b>".$hair_color ."</b></label><br>";
        $strHeader .= "<label style='font-size:17px'><b>Bust/Chest(Inches) :  </b></label><label style='font-size:16px'><b>".$chest."</b></label><br>";
        $strHeader .= "<label style='font-size:17px'><b>Shoe Size(cm)  : </b></label><label style='font-size:16px'><b>".$shoe ."</b></label><br>"; 
        $strHeader .= "<label style='font-size:17px'><b>Eye Color  :  </b></label><label style='font-size:16px'><b>".$eye_color  ."</b></label><br>";
         $strHeader .= "<label style='font-size:17px'><b>Waist(Inches) :  </b></label><label style='font-size:16px'><b>".$waist ."</b></label><br>";
       $strHeader .= "<label style='font-size:17px'><b>Hair Type  :   </b></label><label style='font-size:16px'><b>".$hair ."</b></label><br>";
       $strHeader .= "<h1>Additional Information </h1>";
        //$strHeader .= "<label style='font-size:17px'><b>Occupational Health Card :  </b></label><label style='font-size:16px'><b>".$healthcard."</b></label><br>";
       $strHeader .= "<label style='font-size:17px'><b>Driving License :  </b></label><label style='font-size:16px'><b>".$driving_license."</b></label><br>";
        $strHeader .= "<label style='font-size:17px'><b>Portfolio : </b></label><label style='font-size:16px'><b>".$portfolio."</b></label><br>";
        $strHeader .= "<label style='font-size:17px'><b>Availability : </b></label><label style='font-size:16px'><b>".substr($availability,1)."</b></label><br>";
        $strHeader .= "<label style='font-size:17px'><b>Languages : </b></label><label style='font-size:16px'><b>".substr($langhid, 1)."</b></label><br>";
        $strHeader .= "<label style='font-size:17px'><b>Years of Experience : </b></label><label style='font-size:16px'><b>".$experience."</b></label><br>";
        //$strHeader .= "<label style='font-size:17px'><b>Previous events : </b></label><label style='font-size:16px'><b>".$prvs_events."</b></label><br>";
        $strHeader .= "<label style='font-size:17px'><b>Avg Hourly/Daily Rate(In AED) : </b></label><label style='font-size:16px'><b>".$avg_pay."</b></label><br>";
       // $strHeader .= "<label style='font-size:17px'><b>Dubai Duty Free License : </b></label><label style='font-size:16px'><b>".$duty_free."</b></label><br>";
        $strHeader .= "<label style='font-size:17px'><b>Remarks : </b></label><label style='font-size:16px'><b>".$remarks."</b></label>nn";
    //*** Attachment ***//
    for($i=0;$i<count($_FILES["model_photos"]["name"]);$i++)
    {
        if($_FILES["model_photos"]["name"][$i] != "")
        {
            $strFilesName = $_FILES["model_photos"]["name"][$i];
            $strContent = chunk_split(base64_encode(file_get_contents($_FILES["model_photos"]["tmp_name"][$i]))); 
            $strHeader .= "--".$strSid."n";
            $strHeader .= "Content-Type: application/octet-stream; name="".$strFilesName.""n"; 
            $strHeader .= "Content-Transfer-Encoding: base64n";
            $strHeader .= "Content-Disposition: attachment; filename="".$strFilesName.""nn";
            $strHeader .= $strContent."nn";
        }
    }
    for($i=0;$i<count($_FILES["passport"]["name"]);$i++)
    {
        if($_FILES["passport"]["name"][$i] != "")
        {
            $strFilesName = $_FILES["passport"]["name"][$i];
            $strContent = chunk_split(base64_encode(file_get_contents($_FILES["passport"]["tmp_name"][$i]))); 
            $strHeader .= "--".$strSid."n";
            $strHeader .= "Content-Type: application/octet-stream; name="".$strFilesName.""n"; 
            $strHeader .= "Content-Transfer-Encoding: base64n";
            $strHeader .= "Content-Disposition: attachment; filename="".$strFilesName.""nn";
            $strHeader .= $strContent."nn";
        }
    }
    if($portfolio=="Yes")
    {
    if($_FILES["portfolio_already"]["name"] != "")
        {
            $strFilesName = $_FILES["portfolio_already"]["name"];
            $strContent = chunk_split(base64_encode(file_get_contents($_FILES["portfolio_already"]["tmp_name"]))); 
            $strHeader .= "--".$strSid."n";
            $strHeader .= "Content-Type: application/octet-stream; name="".$strFilesName.""n"; 
            $strHeader .= "Content-Transfer-Encoding: base64n";
            $strHeader .= "Content-Disposition: attachment; filename="".$strFilesName.""nn";
            $strHeader .= $strContent."nn";
        }
    }
    for($i=0;$i<count($_FILES["resume"]["name"]);$i++)
    {
        if($_FILES["resume"]["name"][$i] != "")
        {
            $strFilesName = $_FILES["resume"]["name"][$i];
            $strContent = chunk_split(base64_encode(file_get_contents($_FILES["resume"]["tmp_name"][$i]))); 
            $strHeader .= "--".$strSid."n";
            $strHeader .= "Content-Type: application/octet-stream; name="".$strFilesName.""n"; 
            $strHeader .= "Content-Transfer-Encoding: base64n";
            $strHeader .= "Content-Disposition: attachment; filename="".$strFilesName.""nn";
            $strHeader .= $strContent."nn";
        }
    }

    if(trim($fname)!='' && trim($gender)!='')   
    {
    if(@mail($strTo,$strSubject,"null",$strHeader))
    {
        echo "<script>window.location.href = '".  get_site_url()."/index.php/application/?suc=1'</script>";
    }
    else
    {
        echo "<script>window.location.href = '".  get_site_url()."/index.php/application/?suc=0'</script>";
        print_r(error_get_last()); 
    }
    }
    else
    {
        echo "<script>window.location.href = '".  get_site_url()."/index.php/application/?suc=0'</script>";
        print_r(error_get_last()); 
    }

?>

返回错误是Array ([type] => 2 [message] => mail():在additional_header中发现多个或错误的换行

这段代码在我的服务器上工作得很好,但它不能在godaddy服务器上工作,我的问题是如何使这段代码在godaddy服务器

提示:

将其改为(^^ in first one)

    echo "<script>window.location.href = '".   `  `     get_site_url()."/index.php/application/</script>";
                                               ^  ^

    echo "<script>window.location.href = '". get_site_url()."/index.php/application/</script>";

因为有一个错误。修复它

最新更新