在Windows 8上无法发送带有php邮件功能的邮件 [英] Can't send email with php mail function on windows 8

查看:154
本文介绍了在Windows 8上无法发送带有php邮件功能的邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



有错误:


警告:mail()[function.mail]:无法连接到
localhost端口25的邮件服务器,验证
php.ini中的SMTP和smtp_port设置,或使用ini_set )在C:\wamp\www\mail.php第9行


这是简单的源代码: p>

 <?php 
//消息
$ message =Line 1\r\\\
Line 2\\\\
Line 3;

//如果我们的任何行大于70个字符,我们应该使用wordwrap()
$ message = wordwrap($ message,70,\\\\ );

//发送
邮件('caffeinated@example.com','我的主题',$ 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




重要提示:如果在另一个 sendmail_path php.ini sendmail_path =C:\xampp\mailtodisk\mailtodisk.exe



注意:在我的Windows 8.1中测试并正常工作



I have installed wamp on windows 8.

Got error:

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

Here is the simple source code:

<?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);
?>

Which software do i have to install to email through php on windows 8? sendmail, msmtp or ssmtp?

解决方案

Try this

Configure This Setups

in php.ini

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

in 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 8上无法发送带有php邮件功能的邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆