本文介绍了php电子邮件不发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我发送电子邮件的PHP代码。我得到按摩'消息被发送,你可以发送另一个。但是电子邮件没有发送。我正在使用Cpanel来托管我的网站。这有什么特殊配置吗?我是php的新手。请帮我。
This is my php code to send email. I got the massage 'Message was sent, you can send another one. But email is not sending.I am Using Cpanel to host my web site. Is there any special configurations to do this? I'm new to php. Please help me.
<h4>Please fill out the following form and we will be in touch with you soon.</h4>
<form action="mytest.php" method="post" id="contactform">
<ol>
<li>
<label for="name">Your Name <span class="red">*</span></label>
<input id="name" name="name" class="text" />
</li>
<li>
<label for="email">Your email <span class="red">*</span></label>
<input id="email" name="email" class="text" />
</li>
<li>
<label for="subject">Subject</label>
<input id="subject" name="subject" class="text" />
</li>
<li>
<label for="message">Message <span class="red">*</span></label>
<textarea id="message" name="message" rows="6" cols="50"></textarea>
</li>
<li class="buttons">
<input type="image" name="imageField" id="imageField" src="images/send.gif" class="send" />
<div class="clr"></div>
</li>
</ol>
</form>
<?php
if(!$_POST) exit;
$email = $_POST['email'];
$errors=0;
if($errors==1) echo $error;
else{
$email_from = $_POST['email'];
$email_from = "[email protected]";
$headers = "From: " . strip_tags( $_POST['name'] ) . "\r\n";
$mail_to_send_to = "[email protected]";
$your_feedbackmail = "[email protected]";
$sendflag = 'send';
if ( $sendflag == "send" )
{
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
$headers = "From: $your_feedbackmail" . "\r\n" . "Reply-To: $email" . "\r\n" ;
$a = mail( $mail_to_send_to, "Feedback Form Results", $message, $headers );
if ($a)
{
print("Message was sent, you can send another one");
} else {
print("Message wasn't sent, please check that you have changed emails in the bottom");
}
}
}
?>
推荐答案
这篇关于php电子邮件不发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!