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

标签 php email localhost wamp

调用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/

相关文章:

php - localhost wordpress 重定向到 XAMPP 站点

iphone - 如何从 iPhone 浏览器访问在 localhost 上运行的网站

php - 灯箱根据我按下的内容显示内容

php - 如果发现重复值,将数组添加在一起?

.net - 在 .NET 中通过 GMail 发送电子邮件

xcode - 您如何通过电子邮件发送 Swift 自动化测试结果?

php - 如何每 36 小时运行一次 crontab

php - 如何创建其他连接 zf2 apigility?

html - 在 Gmail 中将 HTML 电子邮件正文居中

http - keepalived健康检查无法连接到127.0.0.1