无法通过 php mail() 发送邮件

2022-01-23 00:00:00 email gmail php html

我无法通过 php 的邮件功能发送电子邮件.

I am unable to send an email via php's mail function.

这是我收到的错误.警告:mail() [function.mail]:无法在localhost"端口 25 连接到邮件服务器,请验证 php.ini 中的SMTP"和smtp_port"设置或在 D:inetpubvhosts 中使用 ini_set()Southernbatteries.comhttpdocsincludesutils.php 在第 6 行数组( [0] => [1] => 无法发送邮件,请稍后再试...)

This is the error I receive. 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 D:inetpubvhostssouthernbatteries.comhttpdocsincludesutils.php on line 6 Array ( [0] => [1] => Could not send mail, please try later... )

这到底是什么意思?这是否意味着我的网络服务器上没有安装邮件服务器?是否可以使用不同的邮件服务器.例如 Gmails 邮件服务器发送邮件?

What exactly does this mean ? Does it mean there is not mail server installed on my webserver ? Is it possible to use a different mail server. E.g Gmails mail server to send the mail ?

推荐答案

如果你想使用内置的mail(),你需要和服务器管理员联系.在 Windows 上可以使用外部 SMTP 服务器,但必须在 php.ini 设置中指定,并且 PHP 的内置函数不支持 SMTP 身份验证.

If you want to use built-in mail(), you will need to talk to the server administrator. It is possible to use an external SMTP server on Windows, but it has to be specified in the php.ini settings, and PHP's built-in functions don't support SMTP authentication.

通常的方法是使用本地邮件服务器,该服务器反过来可以与真正的"SMTP 服务器通信,或者使用像 SwiftMailer 可以直接连接到 GMail 等第 3 方 SMTP 服务器.

The usual way is to either use a local mail server that in turn can talk to a "real" SMTP server with authentication, or use a mailing package like SwiftMailer that can connect to a 3rd party SMTP server like GMail directly.

相关文章