我的应用程序已在许多网站上传。其中一个功能是我可以使用php mail()函数发送电子邮件。问题是,在其中一个上,邮件功能不会发送电子邮件。
以下代码是我用来发送电子邮件的代码。它适用于其他7个站点,但是在8日它没有:
if(isset($_REQUEST) && isset($_POST['email']) && isset($_POST['subject'])){
if((!empty($_POST['email'])) && (!empty($_POST['subject'])))
{
$to = $_POST['to'];
$subject = "Re: ".$_POST['subject'];
$message = $_POST['email'];
$headers = array();
$headers[] = "Reply-To: ".$_SESSION['name']." ".$_POST['from'];
$headers[] = "Return-Path: ".$_SESSION['name']." ".$_POST['from'];
$headers[] = "From: ".$_SESSION['name']." ".$_POST['from'];
$headers[] = "Organization: **********";
$headers[] = "Subject: {$subject}";
$headers[] = "Date: ".date(DATE_RFC2822);
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-Type: text/html; charset=utf-8";
$headers[] = "X-Priority: 1";
$headers[] = "X-Mailer: PHP/" . phpversion();
mail($to,stripslashes($subject),stripslashes($message),implode("\r\n",$headers));
$user= $_POST['the_id'];
$now = date("H:i:s");
$date = date("Y-m-d");
$feedback_id = $_POST['f_id'];
mysql_query("INSERT INTO chain_email(user_email,time,date,user_id,feedback_id,email) VALUES('$to','$now','$date','$user','$feedback_id','$message')",$con);
?>
<script type="text/javascript">
alert("The e-mail has been sent to <?php echo $_POST['to']; ?> at <?php echo $now; ?> on <?php echo $date; ?>");
</script>
<?php
} else {
?>
<script type="text/javascript">
alert("The e-mail could not be sent. Please do not leave the textarea empty!");
</script>
<?php
}
}