php mail()函数不发送邮件

时间:2014-08-25 21:23:32

标签: php email

我配置了我的php.ini和sendmail.ini,我编写了一个简单的代码来发送邮件,但我收到的邮件没有收到任何内容。

<?php 
mail('hmidi_slim@hotmail.fr','test message','1 2 test');
?>

的php.ini:

SMTP = localhost
smtp_port = 25
sendmail_path ="C:\xampp\sendmail\sendmail.exe"

sendmail.ini:

smtp_server=smtp.gmail.com
smtp_port=587
default_domain=gmail.com
auth_username=powerfulcar12@gmail.com
auth_password=password
force_sender=powerfulcar12@gmail.com

1 个答案:

答案 0 :(得分:0)

不要直接使用sendmail PHP函数。它不遵循任何RFC邮件规范,它只是非常简单的PHP函数。在许多RFC出现之前,它曾经足够多年了: - )

使用一些 PHP邮件库,它将为您创建正确的邮件标题+正文并发送电子邮件(通过SMTP,POP3或sendmail)。我建议使用PHPMailer或SwiftMailer - 请参阅this thread on PHP mailing software

您可能也有兴趣在本地测试电子邮件而不将其发送出您的网络 - 请参阅here how to setup environment

相关问题