联系表格不发送邮件

时间:2017-01-17 08:02:15

标签: php html forms contact

我有这个联系表格和PHP,但它根本不会发送电子邮件,我能得到第二眼吗?下面的第一个代码示例来自index.html,PHP来自contact.php

联系表格:

<form action="contact.php" method="POST">
    <p>Name</p> <input type="text" name="name" class="form-control">
    <p>Email</p> <input type="text" name="email" class="form-control">
    <p>Phone</p> <input type="text" name="phone" class="form-control">

    <p>Request Phone Call:</p>
    Yes:<input type="checkbox" value="Yes" name="call" class="form-control">
    No:<input type="checkbox" value="No" name="call" class="form-control">
    <p>Priority</p>
    <select name="priority" size="1" class="form-control">
        <option value="Low" class="form-control">Low</option>
        <option value="Normal" class="form-control">Normal</option>
        <option value="High" class="form-control">High</option>
        <option value="Emergency" class="form-control">Emergency</option>
    </select>

    <p>Message</p><textarea name="message" rows="6" cols="25" class="form-control"></textarea><br />
    <input type="submit" value="Send"class="form-control"><input type="reset" value="Clear" class="form-control">

Contact.php -

<?php
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$call = $_POST['call'];
$website = $_POST['website'];
$priority = $_POST['priority'];
$type = $_POST['type'];
$message = $_POST['message'];
$formcontent=" From: $name \n Phone: $phone \n Call Back: $call \n Priority: $priority \n Message: $message";
$recipient = "test@gmail.com";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";
?>

1 个答案:

答案 0 :(得分:0)

邮件(到,主题,消息,报头,参数);

但是如果您的电子邮件ID代码已修复:test@gmail.com 用$ email更改$收件人。