我有创建邮件PHP代码但不发送电子邮件

时间:2015-10-15 12:26:48

标签: php email

我试着弄出什么问题但没找到。请帮助我。这个代码有什么问题。只有邮件不发送消息才会显示“通过”。 此代码不是发送邮件,但邮件将显示通过。

<?php
$name = $_POST['name'];
$employeestrength = $_POST['employeestrength'];
$companyweb = $_POST['companyweb'];
$contactpersonname = $_POST['contactpersonname'];
$contactnumber = $_POST['contactnumber'];
$emailaddress = $_POST['emailaddress'];
$cityandstste = $_POST['cityandstste'];
$massege = $_POST['massege'];
$captch = $_POST['captch'];

$to = "balvant.alpha@gmail.com";
$subject = "E-mail from HRMSsystem.com for new requirement";
$message = "<br>";
$message .= "<b>Name :</b> $name <br>"; 
$message .= "<b>Email :</b> $employeestrength <br>";
$message .= "<b>organization :</b> $companyweb<br>";     
$message .= "<b>Phone Number:</b> $contactpersonname <br>";  
$message .= "<b>Comapny :</b> $contactnumber <br>"; 
$message .= "<b>City :</b> $emailaddress <br>"; 
$message .= "<b>Description :</b> $cityandstste <br>"; 
$message .= "<b>Massege :</b> $massege <br>"; 
$message .= "<b>captch :</b> $captch <br>"; 
$message .= "<br>";

 $header = "From:no-reply@hrmssystem.com \r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html\r\n";
$body = "We have received the following information:\n\n"; 

$headers2 = "From:no-reply@hrmssystem.com"; 

$subject2 = "Request to get listed into HRMSsystem.com"; 

$message2 = "Dear, Thank you for request and details to list into HRMSsystem.com directory. Our team will verify and list your details into directory as soon as possible. Kindly contact team@hrmssystem.com for more details or questions.";


 $retval = mail($to,$subject,$message,$header);
mail($to, $subject, $body); 

 $send2 = mail($emailaddress, $subject2, $message2,$headers2); 
 if( $retval == true )
 {
   //echo "pass";
header('Location: http://localhost:8080/caofficeautomation/');
}
else{ 
echo "Message could not be sent..."; }



?>

由于 请帮我简短解决这个问题。

1 个答案:

答案 0 :(得分:0)

此外,请检查此答案(如果您尝试从localhost发送邮件)。

php send mail from localhost