电子邮件功能即使在更正代码后也无法正我不知道为什么不发送emal

时间:2016-09-12 09:58:46

标签: php phpmailer html-email

以下是我的电子邮件功能的PHP代码,它不发送电子邮件,我没有得到错误的地方。表单数据正确发布但邮件不会发送。

$imgSrc   = "logo1.png";
$bg = "background.jpg";
$subjectPara1 = "Dear admin";
$subjectPara2 = $_POST["message"];
$subjectPara4 = $_POST["email"];
$subject = $_POST["subject"];
$subjectPara3 = $_POST["author"];
$message = '<!DOCTYPE HTML><html>'.
'<head>'.
'<title>Email notification</title>'.
'</head>'.
'<body style="background-image: url('.$bg.');background-size: cover;">'.
'<div id="header" style="width: 80%;height: 60px;margin: 0 auto;padding: 10px;color: #fff;text-align: left;font-family: Open Sans,Arial,sans-serif;">'.
'<img height="50" width="220" style="border-width:0" src="'.$imgSrc.'" >'.
'</div>'.
'<div id="outer" style="width: 80%;margin: 0 auto;margin-top: 10px;">'. 
'<div id="inner" style="width: 78%;font-family: inherit;font-size: 15px;font-weight: normal;line-height: 1.4em;color: #fff;margin-top: 10px;">'.
'<p>'.$subjectPara1.'</p>'.
'<p>'.$subjectPara2.'</p>'.
'<p><br/>Regards,<br/>'.$subjectPara3.'</p>'.
'<p>'.$subjectPara4.'</p>'.
'</div>'.  
'</div>'.
'<div id="footer" style="width: 80%;height: 40px;text-align: center; padding: 10px; font-family: inherit; font-size: 15px; color: #fff;">'.
'All rights reserved @ 2016'.
'</div>'.
'</body></html>';    
$to      = 'test@exmple.com'; 
$from    = $subjectPara4;           
$headers  = 'From: test@exmple.com\r\n';
$headers .= 'Reply-To:  test@exmple.com\r\n';
$headers .= 'MIME-Version: 1.0\r\n';
$headers .= 'Content-Type: text/html; charset=ISO-8859-1\r\n';
if(mail($to, $subject, $message, $headers))
{
echo "<script>window.location='index.php';</script>";
}

请帮我解决这个问题。

0 个答案:

没有答案