不从php代码中获取电子邮件
表单和PHP代码运行良好,但我唯一的问题是它不会向我或注册者发送电子邮件。请你看看代码,看看我做错了什么 提前谢谢 这就是HTML不从php代码中获取电子邮件,php,email,Php,Email,表单和PHP代码运行良好,但我唯一的问题是它不会向我或注册者发送电子邮件。请你看看代码,看看我做错了什么 提前谢谢 这就是HTML <div id="formWrapper"> <form action="formprocess.php" method="post"> <fieldset class="first"> <h3>Welcome to the SBOCC Questions & Comments Page.<
<div id="formWrapper">
<form action="formprocess.php" method="post">
<fieldset class="first">
<h3>Welcome to the SBOCC Questions & Comments Page.</h3>
<h4>Please fill out the form below with your question(s) or comment(s)<br>
so that you may receive an answer. Shalom (Peace). BLESS THE COMFORTER.
</h4>
<label class="labelOne" for="name">Your Name:</label>
<label class="two" for="optional">(Required)</label>
<input name="name" />
<label for="email">Your Email:</label>
<label class="three" for="required">(Required)</label>
<input name="email" />
<label for="questionscomments">Questions/Comments:</label>
<textarea name="speak"></textarea>
</fieldset>
<fieldset>
<input class="btn" name="submit" type="submit" value="Send Email" />
<input class="btn" name="reset" type="reset" value="Clear Form" />
</fieldset>
<fieldset class="second">
<h4>Would you like to be added to our mailing list?<h4>
<input class="ckbox" type="checkbox" name="mailing" value="yes" checked="yes" /> Yes
<input class="ckbox" type="checkbox" name="mailing" value="no" /> No
</fieldset>
欢迎访问SBOCC问题和评论页面。
请在下表中填写您的问题或意见
这样你就可以得到答案。沙洛姆(和平)。祝福安慰者。
你的名字:
(必选)
您的电子邮件:
(必选)
问题/评论:
您想加入我们的邮件列表吗?
对
不
以下是PHP代码:
<?php
$to = "shealtielyisrael@gmail.com";
$from = $_REQUEST['email'];
$name = $_REQUEST['name'];
$headers = "From: $from";
$subject = "Contact The SBOCC";
$fields = array();
$fields{"name"} = "name";
$fields{"email"} = "email";
$fields{"speak"} = "questions/comments";
$fields{"mailing"} = "newsletter";
$body = "We have received the following information:\n\n"; foreach($fields as $a => $b)
{$body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
$headers2 = "From: noreply@thesbocc.com";
$subject2 = "Thank you for contacting The SBOCC";
$autoreply = "Thank you for contacting us. Your question(s)/comment(s) has been received. Shalom. Bless the comforter";
if($name == '') {print "You have not entered a name, please go back and try again";}
else {
if($from == '') {print "You have not entered an email, please go back and try again";}
else {
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
if($send)
{header( "Location: thankyou.html");}
else
{print "We encountered an error sending your mail, please notify shealtielyisrael@gmail.com";}
}
}
?>
亲爱的,如果您使用的是像XAMPP或APPSERV之类的本地服务器,您必须在本地计算机上安装邮件服务器 如果您使用的是真正的主机服务器,请确保服务器中的php设置允许您使用邮件功能,因为许多服务器已停止此功能 所以我建议您使用smtp发送邮件,请看这里 还有一个功能强大的库,可以向PHPMailer发送电子邮件
是否在本地主机上进行测试?尝试使用服务器上的命令行发送邮件。检查它是否工作..是否选中垃圾邮件框?是否确定使用邮件服务器?检查邮件服务器日志,了解那里发生了什么。感谢大家的快速和有用的响应。我确实在使用XAMPP,我没有安装邮件服务器,因为我认为它不需要它。感谢艾哈迈德和所有愿意帮助的人。