通过我的表单发送电子邮件的麻烦

时间:2013-11-18 04:22:53

标签: php forms email

我试图让我的表单通过电子邮件发送给自己,但我无法通过电子邮件发送电子邮件。一切都被正确地带了,所以我不明白为什么没有被送去。

<?php
if(isset($_POST['form2']))
{
$to = $_POST['kyle*****@sbcglobal.net'];
$from = $_POST['from'];
$subject = $_POST['subject'];
$parent = $_POST['parent'];
$child = $_POST['child'];
$age = $_POST['age'];
$gender = $_POST['gender'];
$address = $_POST['address'];
$number = $_POST['number'];
$comments= $_POST['comments'];
mail("$to", "$comments", "$subject", "From: $from\r\nReply-To: $from\r\n");

    if ($from !="" && $subject !="" && $parent !="" && $child !="" && $age !="" 
    && $gender !="" && $number !="")
    {
    print"Thank you for submitting your information. You should be contacted     soon.";
    }
    else
    {
    print "Please fill out all the required sections!";
    }
}


?>

2 个答案:

答案 0 :(得分:0)

我认为这可能是一个错误:

$to = $_POST['kyle*****@sbcglobal.net'];

这告诉PHP要从名为'kyle * * * @ sbcglobal.net'的表单输入中查找通过POST提交的值。

另外,您是否已验证正在运行此代码的任何环境是否已正确配置为发送电子邮件?

答案 1 :(得分:-1)

试试这个..

<!DOCTYPE html>
<html>
<body>

<h3>Send e-mail to kyle*****@sbcglobal.net:</h3>

<form action="MAILTO:kyle*****@sbcglobal.net" method="post" enctype="text/plain">
Name:<br>
<input type="text" name="name" value="your name"><br>
E-mail:<br>
<input type="text" name="mail" value="your email"><br>
Comment:<br>
<input type="text" name="comment" value="your comment" size="50"><br><br>
<input type="submit" value="Send">
<input type="reset" value="Reset">
</form>

</body>
</html>