gpt4 book ai didi

php - 如何使用 WAMP 测试发送邮件

转载 作者:搜寻专家 更新时间:2023-10-31 20:43:07 24 4
gpt4 key购买 nike

调用the mail function时它产生错误

Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()

我正在使用 Wampserver 2,我认为错误是因为 Wamp 没有附带邮件服务器。然后我添加了以下代码 ( as per an answer here )

ini_set("SMTP","aspmx.l.google.com");
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
$headers .= "From: test@gmail.com" . "\r\n";
mail("email@domain.com","test subject","test body",$headers);

它产生了以下错误

Failed to connect to mailserver at "aspmx.l.google.com" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()

在位于 C:\wamp\bin\php\php5.4.3 的 php.ini 文件中,它包含以下设置

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = you@yourdomain

如何在本地运行文件时发送电子邮件?

在我工作的地方,公司 ISP 将哪些信息用于邮件(事实上,公司是它自己的 ISP)确实不可靠。有没有另一种方法可以在没有找到正确端口的情况下进行测试(如果存在的话)?

最佳答案

安装 smtp4dev 就完成了

http://smtp4dev.codeplex.com/

关于php - 如何使用 WAMP 测试发送邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17954564/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com