在Windows 8上无法发送带有php邮件功能的邮件

前端之家收集整理的这篇文章主要介绍了在Windows 8上无法发送带有php邮件功能的邮件前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我已经在 windows 8上安装了wamp.

错误

Warning: mail() [function.mail]: Failed to connect to mailserver at
“localhost” port 25,verify your “SMTP” and “smtp_port” setting in
PHP.ini or use ini_set() in C:\wamp\www\mail.PHP on line 9

这里是简单的源代码

<?PHP
// The message
$message = "Line 1\r\nLine 2\r\nLine 3";

// In case any of our lines are larger than 70 characters,we should use wordwrap()
$message = wordwrap($message,70,"\r\n");

// Send
mail('caffeinated@example.com','My Subject',$message);
?>

我必须通过PHP在Windows 8上安装哪些软件来发送电子邮件? sendmail,msmtp或ssmtp?

尝试这个

配置此设置

PHP.ini

SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = my-gmail-id@gmail.com
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

在sendmail.ini中:

smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=my-gmail-id@gmail.com
auth_password=my-gmail-password
force_sender=my-gmail-id@gmail.com

Important: comment following line if there is another sendmail_path in the PHP.ini : sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe"

Note: Tested and works fine in my Windows 8.1

猜你在找的Windows相关文章