无法在 Windows 8 上使用 php 邮件功能发送电子邮件 [英] Can't send email with php mail function on windows 8

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

问题描述

我已经在 Windows 8 上安装了 wamp.

出现错误:

<块引用>

警告:mail() [function.mail]:无法连接到邮件服务器本地主机"端口 25,验证您的SMTP"和smtp_port"设置php.ini 或在 C:wampwwwmail.php 第 9 行使用 ini_set()

这是简单的源代码:

我必须安装哪些软件才能通过 Windows 8 上的 php 发送电子邮件?sendmail、msmtp 还是 ssmtp?

解决方案

试试这个

配置此设置

php.ini

SMTP=smtp.gmail.comsmtp_port=587sendmail_from = my-gmail-id@gmail.comsendmail_path = ""C:xamppsendmailsendmail.exe" -t"

sendmail.ini中:

smtp_server=smtp.gmail.comsmtp_port=587error_logfile=error.logdebug_logfile=debug.logauth_username=my-gmail-id@gmail.comauth_password=my-gmail-passwordforce_sender=my-gmail-id@gmail.com

<块引用>

重要提示:如果 php.ini 中还有另一个 sendmail_path ,请注释以下行:sendmail_path="C:xamppmailtodiskmailtodisk.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:wampwwwmail.php on line 9

Here is the simple source code:

<?php
// The message
$message = "Line 1
Line 2
Line 3";

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

// 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:xamppsendmailsendmail.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:xamppmailtodiskmailtodisk.exe"

Note: Tested and works fine in my Windows 8.1

这篇关于无法在 Windows 8 上使用 php 邮件功能发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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