PHP邮件没有被发送

时间:2015-09-06 00:28:34

标签: php

我无法在注册后发送带有php的确认电子邮件。这通常有效,但事实并非如此。我不知道我哪里出错了。请帮我。 请忽略这句话因为stackoverflow不允许我发布这个没有更多细节

<?php
require_once 'includes/constants.php';
// Create connection
$conn = mysqli_connect(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME);
// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}
$username = $_POST['username'];
$pwd = $_POST['pwd'];
$password = md5($pwd);
$email = $_POST['email'];

$query = "SELECT * FROM users WHERE username='$username'";

$result = $conn->query($query) or die($conn->error);

$num = $result->num_rows;

if($num > 0) {
    echo 'name already exist';
}else {
    $sql = "INSERT INTO users (username, email, password, verified) VALUES ('$username', '$email', '$password', 'false')";
        if (mysqli_query($conn, $sql)) {
            $id = $conn->insert_id;

        $subject = "Confirm Codepal Account";

        $headers = "From: accounts@palash.comeze.com\r\n";
        $headers .= "Reply-To: accounts@palash.comeze.com\r\n";

        $message = "Please confirm Account http://palash.comeze.com/verify.php?id=".  $id." ";

        mail($email, $subject, $message, $headers);
            header("Location: ves.html");
        }else {
            echo "Error: " . $sql . "<br>" . mysqli_error($conn);
        }

}
mysqli_close($conn);
?>

0 个答案:

没有答案