邮件功能无法在实时服务器上运行

时间:2018-04-09 17:24:29

标签: php html email gmail

请帮帮我。我是PHP新手。我的邮件功能即使在实时服务器上也不起作用。我不知道我的代码有什么问题。

<div class="contact-form">
            <h4>Get in Touch</h4>
            <form name="contactform" method="post" action="send_form_email.php">
                <div class="col-md-6 form-left">
                    <input type="text" placeholder="Name" name="name" required="">
                </div>
                <div class="col-md-6 form-right">
                    <input class="email" type="email" name="email" placeholder="Email" required="">
                </div>
                <div class="clearfix"> </div>
                    <input class="" type="text" placeholder="Phone" name="phone" required="">
                    <textarea class="" placeholder="Message" name="message" required=""></textarea>
                    <input type="submit" value="SUBMIT" >
            </form>
        </div>

这是我的邮件功能文件。名称为send_form_email.php。

    <?php 
if(isset($_POST['submit'])){
    $to = "ali.gohar@gmail.com"; // this is your Email address
    $from = $_POST['email']; // this is the sender's Email address
    $name = $_POST['first_name'];
    $phone = $_POST['phone'];
    $message = $name . " " . $email . " " . $phone . "wrote the following:" . "\n\n" . $_POST['message'];


    $headers = "From:" . $from;
    $headers2 = "From:" . $to;
    mail($to,$subject,$message,$headers);

    echo "Mail Sent. Thank you " . $name . ", we will contact you shortly.";

    }
?>

0 个答案:

没有答案