PHP mail() doesn't work [duplicate]

2020-02-01 03:23发布

I want to script a simple registration form with activation mail and so on. But for some reason mail() doesn't send the emails, or my 3 different email accounts (hotmail,gmail,yahoo) don't receive them and therefore don't even put them in the spam folder.

Code:

<?php
    $mailto = 'xxx@example.com';
    $subject = 'the subject';
    $message = 'the message';
    $from = 'system@example.net';
    $header = 'From:'.$from;

    if(mail($mailto,$subject,$message,$header)) {
        echo 'Email on the way';
    }
?>

Everytime it outputs 'Email on the way' so mail() returns true, right? I really don't get it, I've even tried to turn off my little snitch (although I didn't block SMTP).

标签: php email
7条回答
孤傲高冷的网名
2楼-- · 2020-02-01 04:17

Check your phpinfo and/or php.ini for your mail settings and make sure you can send mail with whatever program php is trying to use. The function will succeed if the command executes but doesn't know if the mail actually went out.

查看更多
登录 后发表回答