PHP邮件功能不工作/不发送电子邮件

时间:2016-05-31 17:51:57

标签: php phpmailer

我知道有很多关于此的帖子,但我的似乎没有在这里工作。该行从数据库中获取正常,但不发送邮件。这是我的代码。

<form action="<?php echo $_SERVER['PHP_SELF'];?>" method = "POST">

<input type = "email" name = "email" placeholder = "Enter Your Email Address" required/>
<input type = "submit" name= "submit" value = "submit"/>

</form>

php代码

function sendEmail(){
            $to = "someone@gmail.com";
            $subject = "the subject";
            $message = "First line";
            $headers = 'From: someone@example.com' . "\r\n" .'Reply-To: someone@example.com' . "\r\n" .'X-Mailer: PHP/' . phpversion();

            mail($to, $subject, $message, $headers);
    }


if(isset($_POST['submit']) && $_POST['submit'] == 'submit'){
    $email = $_POST['email'];

    $sql = $db->prepare("SELECT * from users where email = ?");
    $sql->bind_param("s",$email);
    $sql->execute();
    $sql = $sql->get_result();

    if(($getRowCount = $sql->num_rows) == 1){
            sendEmail();
}

0 个答案:

没有答案