Php 服务器和邮件功能

Php 服务器和邮件功能,php,email,server-side,Php,Email,Server Side,*我发邮件有问题 此脚本在本地主机上有效,但在服务器上无效 本地主机上的邮件处理功能和其他服务器上的邮件处理功能有区别吗* 在第4个和第5个选项中,参数在中被禁用,并且mail()函数将显示一条警告消息,使用时返回FALSE 换句话说,您的服务器可能启用了安全模式。使用第四个参数: 回信($rname.“,$subject,$fullmessage,$header) 也可能是服务器的sendmail安装不正确或根本没有安装。检查phpinfo()以查看它是否已启用/注册。如果所有其他操作都失败

*我发邮件有问题 此脚本在本地主机上有效,但在服务器上无效 本地主机上的邮件处理功能和其他服务器上的邮件处理功能有区别吗*


在第4个和第5个选项中,参数在中被禁用,并且mail()函数将显示一条警告消息,使用时返回FALSE

换句话说,您的服务器可能启用了安全模式。使用第四个参数:

回信($rname.“,$subject,$fullmessage,$header)


也可能是服务器的sendmail安装不正确或根本没有安装。检查phpinfo()
以查看它是否已启用/注册。如果所有其他操作都失败,请致电您的web服务器主机或提交一张罚单。

请注意,这个问题让MedDescripte头疼,无法正常工作。什么时候会失败?你应该更详细地描述实际问题。是否显示错误?哪个功能失败了?我真的很感谢你:)主持人心情很好谢谢
<?php
session_start();
error_reporting(E_ALL & ~E_NOTICE);

/**
* this function is made to upload multiple files
*@param string $file (input name)
*@return nothing
*/
function upload($file)
{
    for($i=0; $i<count($_FILES[$file]['name']); $i++) {
  //Get the temp file path
  $file_name = $_FILES[$file]['name'][$i];
  $type = $_FILES[$file]['type'][$i];
  $tmpFilePath = $_FILES[$file]['tmp_name'][$i];
  //Make sure we have a filepath
  if ($tmpFilePath != ""){
    //Setup our new file path
   global $newFilePath;
   $newFilePath  = "uploadFiles/" . $_FILES[$file]['name'][$i];
   global $files;
   $files[] = array($newFilePath.':'.$type.':'.$file_name);
   //echo $files;


   //Upload the file into the temp dir
    if(move_uploaded_file($tmpFilePath, $newFilePath)) {

     echo "تم رفع الملفات بنجاح";

    }
    else{
        echo "حدث خطا فى رفع الملفات";
    }
  }
}
}






if($_POST['contact'])
{



    if($_POST['name'] && $_POST['email'] && $_POST['phone'] && $_POST['others'] && $_FILES['img'])
    {
        $name = $_POST['name'];
        $email = $_POST['email'];
        $phone = $_POST['phone'];
        $others = $_POST['others'];
        $others = implode(" and ", $others);
        upload("img");
      foreach ($files as $index => $file) {
  foreach ($file as   $value) {
    $a[] = $value;
  }
}
}
    else
    {
      $_SESSION['message'] = "please fill all require fields";
      header('Location: contact.php');
    }
}



?>

<?php
$RecipientEmail = "mohammed_habibphp@yahoo.com"; 

$RecipientName = "mohammed habib";

$SenderEmail = $email; 

$SenderName = $name;

$subject = "coding";

$cc = "alice@example.com, bob@example.com"; 

$bcc = "johndoe@example.com";


// For HTML
$type = "HTML";
// For plain text
//$type = "plain";


$message ="<b>customer name</b>: ".$name.


"<br /><b>email</b>: ".$email.


"<br /><b>phone</b>: ".$phone.


"<br /><b>others</b>: ".$others;





// For normal leave it blank
$priority = "high";

$attachments =$a;


$sent = Email($RecipientEmail, 
              $RecipientName, 
              $SenderEmail, 
              $SenderName, 
              $cc, 
              $bcc, 
              $subject, 
              $message, 
              $attachments, 
              $priority, 
              $type);

echo $sent ? "It worked!!" : "It didn't work"; 
// ^ This is used to test if it worked

// This work is licensed under a Creative Commons Attribution-NonCommercial 3.0 Unported License

function Email($remail, $rname, $semail, $sname, $cc, $bcc, $subject, $message, $attachments, $priority, $type)  {

// Checks if carbon copy & blind carbon copy exist
if($cc != null){$cc="CC: ".$cc."\r\n";}else{$cc="";}
if($bcc != null){$bcc="BCC: ".$bcc."\r\n";}else{$bcc="";}

// Checks the importance of the email
if($priority == "high"){$priority = "X-Priority: 1\r\nX-MSMail-Priority: High\r\nImportance: High\r\n";}
elseif($priority == "low"){$priority = "X-Priority: 3\r\nX-MSMail-Priority: Low\r\nImportance: Low\r\n";}
else{$priority = "";}

// Checks if it is plain text or HTML
if($type == "plain"){$type="text/plain";}else{$type="text/html";}

// The boundary is set up to separate the segments of the MIME email
$boundary = md5(@date("Y-m-d-g:ia"));

// The header includes most of the message details, such as from, cc, bcc, priority etc. 
$header = "From: ".$sname." <".$semail.">\r\nMIME-Version: 1.0\r\nX-Mailer: PHP\r\nReply-To: ".$sname." <".$semail.">\r\nReturn-Path: ".$sname." <".$semail.">\r\n".$cc.$bcc.$priority."Content-Type: multipart/mixed; boundary = ".$boundary."\r\n\r\n";    

// The full message takes the message and turns it into base 64, this basically makes it readable at the recipients end
$fullmessage = "--".$boundary."\r\nContent-Type: ".$type."; charset=UTF-8\r\nContent-Transfer-Encoding: base64\r\n\r\n".chunk_split(base64_encode($message));

// A loop is set up for the attachments to be included.
if($attachments != null) {
  foreach ($attachments as $attachment)  {
    $attachment = explode(":", $attachment);
    print_r($attachment);

    $fullmessage .= "--".$boundary."\r\nContent-Type: ".$attachment[1]."; name=\"".$attachment[2]."\"\r\nContent-Transfer-Encoding: base64\r\nContent-Disposition: attachment\r\n\r\n".chunk_split(base64_encode(file_get_contents($attachment[0])));
  }
}

// And finally the end boundary to set the end of the message
$fullmessage .= "--".$boundary."--";

return mail($rname."<".$remail.">", $subject, $fullmessage, $header);
}

?>