php mail()邮件发送成功但没有收到

时间:2018-03-27 18:49:48

标签: php email

我正在尝试使用php函数mail()发送和发送电子邮件。我明白,如果函数返回true,则不一定意味着邮件已被发送。

我安装了phpmail软件包和libphp-phpmailer软件包,但仍然没有...

这是代码:

<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    Name: <input type="text" name="name"/>
    Mail: <input type="text" name="mail"/>
    <input type="submit" value="Send"/>
</form>
<?php

ini_set('display_errors', 1);
error_reporting(~0);

if (isset($_POST["mail"]) && isset($_POST["name"])) {
    $to_mail = $_POST["mail"];
    $to_name = ucfirst($_POST["name"]);
    $subject = "Sent using php";
    $message = "Hi " . $to_name . ", we're glad you could join us. Hope you like our page and that you're studing a lot! Good luck with whatever you're doing! :D";
    $from = "email@gmail.com";

    if(mail($to_mail, $subject, $message, $from)) {
        echo "E-Mail Sent to " . $to_mail;
    } else {
        echo "Could not send E-Mail";
    }
}
?>

0 个答案:

没有答案