如何配置XAMPP PHP通过我的ISP安全smtp从localhost发送邮件

时间:2013-11-11 14:10:08

标签: php email xampp localhost

对于发送电子邮件,我通常使用Windows 7 Thunderbird通过我的ISP配置安全SMTP(即SMTP服务器的登录名和密码)。连接安全性:无,密码传输不安全。邮件发送正常。

我尝试配置XAMPP php.ini

[mail function]
SMTP=*my_isp_smtp_server*
smtp_port=25
sendmail_from=*my_email_address*
sendmail_path="\"c:\xampp\sendmail\sendmail.exe\" -t"
mail.add_x_header = Off

和sendmail.ini

smtp_server=*smtp_server.my.isp*
smtp_port=25
error_logfile=error.log
debug_logfile=debug.log
auth_username=*login_to_my_isp_smtp_server*
auth_password=*password_to_my_isp_smtp_server*
force_sender=*my_email_address*

在我的php脚本中,我使用标准的php函数:

mail($recipient, $subject, $message, $headers);

我没有收到任何错误消息,但邮件未送达。 你能帮助我吗?

1 个答案:

答案 0 :(得分:0)

对于使用 sendmail 包仍在寻找解决方案的同时仍在努力解决此问题的每个人,您可以将其配置为使用 SMTP 安全服务器,例如 gmail 强>。为了简单起见,我将在下面使用gmail服务器的示例中进行演示,但是您可以使用hMailServer设置自己的SMTP服务器。 here提供了文档,它使用端口 465 用于 TLS 。您只需要从以下gmail配置中更改 SMTP服务器端口地址密码。结构保持不变。

hmailserver

例如,如果要使用gmail路由,请检查以下参数heregmailserver

因此,请进行以下更改:

C:\xampp\php\php.ini中取消注释extension=php_openssl.dll,然后重新启动Apache 以添加 SSL 支持。同样按照文档指南中的说明更改这些值,并相应地设置sendmail_from

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

然后在C:\xampp\sendmail\sendmail.ini中反映这些更改:

[sendmail]

smtp_server=smtp.gmail.com
smtp_port=587
auth_username=yourgmailaddress@gmail.com
auth_password=yourgmailpassword
force_sender=yourgmailaddress@gmail.com