PHP Mail()函数不发送电子邮件

时间:2018-10-15 11:52:30

标签: php email

我的mail()函数不发送电子邮件。我正在测试它是否适用于此代码。

$email_to = 'myemail@gmail.com';
$email_subject = "Test mail";
$email_body = "Hello! This is a simple email message.";
$from = "myemail@gmail.com";

if(mail($email_to, $email_subject, $email_body)){
    echo "The email($email_subject) was successfully sent.";
} else {
    echo "The email($email_subject) was NOT sent.";
}

每次执行代码时,它都会:

  

电子邮件(测试邮件)已成功发送。

但是,我没有收到电子邮件。我不使用Xampp,也没有sendmail.ini文件来修改它。我只是这样修改了php.ini文件:

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.gmail.com
; http://php.net/smtp-port
smtp_port = 587

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = myemail@gmail.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = ""

我想念什么?

0 个答案:

没有答案