[英]PHP mail is not sending email to my email address
I've been looking around everywhere and cannot seem to find how to make this work - it is simply not sending an email to my address. 我到处都在四处逛逛,似乎找不到如何进行这项工作-只是没有向我的地址发送电子邮件。 Here is my HTML form:
这是我的HTML表单:
<form id="contactMe" name="contact" method="post" novalidate="novalidate">
<fieldset>
<label for="name" id="name">Name<span class="required">*</span></label>
<input type="text" name="name" id="name" size="30" value="" required="">
<label for="email" id="email">Email<span class="required">*</span></label>
<input type="text" name="email" id="email" size="30" value="" required="">
<label for="phone" id="phone">Phone</label>
<input type="text" name="phone" id="phone" size="30" value="">
<label for="Message" id="message">Message<span class="required">*</span></label>
<textarea name="message" id="message" required=""></textarea>
<label for="Answer" id="answer">Name the house pet that says “<i>woof</i>“<span class="required">*</span></label>
<input type="text" name="answer" value="" required=""></br>
<input id="submit" type="submit" name="submit" value="Send">
</fieldset>
<div id="success">
<span class="green textcenter">
<p>Your message was sent successfully! I will be in touch as soon as I can.</p>
</span>
</div> <!-- closes success div -->
<div id="error">
<span><p>Something went wrong, try refreshing and submitting the form again.</p></span>
</div> <!--close error div-->
</form>
and here is my PHP saved as mailer.php: 这是我的PHP另存为mailer.php:
<?php
$to = "someone@gmail.com";
$from = $_REQUEST['email'];
$name = $_REQUEST['name'];
$headers = "From: $from";
$subject = "You have a message from your.";
$fields = array();
$fields{"name"} = "name";
$fields{"email"} = "email";
$fields{"phone"} = "phone";
$fields{"message"} = "message";
$body = "Here is what was sent:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
mail("maytee.kneitz@gmail.com",$subject,$message,"From: $from\n");
echo 'Mail sent';
?>
This is my first shot at working on a mailer / contact form, so sorry if it's a blatant problem. 这是我处理邮件/联系表单的第一枪,如果这是一个公然的问题,敬请原谅。 I just can't seem to find it.
我似乎找不到。 Any guidance would be appreciated.
任何指导将不胜感激。
I do have validation in my scripts (not posted here). 我的脚本中确实有验证(未在此处发布)。
You don't have a form action defined. 您没有定义表单操作。 Try this:
尝试这个:
<form id="contactMe" name="contact" method="post" action="mailer.php" novalidate="novalidate">
By default, the form will be submitted to its current location unless otherwise specified. 默认情况下,除非另有说明,否则表单将提交到其当前位置。 In your case, point it to wherever your mail script is located
根据您的情况,将其指向您的邮件脚本所在的位置
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.