SMTP 服务器响应:530 5.7.0 必须先发出 STARTTLS 命令

2022-01-17 00:00:00 smtp php

SMTP 服务器响应:530 5.7.0 必须先发出 STARTTLS 命令

SMTP server response: 530 5.7.0 Must issue a STARTTLS command first

当我在 php 脚本文件中使用 mail() 函数时收到此错误消息...

I get this error message when i use mail() function in php script file...

我使用的是 gmail SMTP 服务器,而 gmail 使用的是安全 SSL 的 STARTTLS我已经在我的contact.php文件中使用了这些命令

I m using gmail SMTP server and gmail using STARTTLS which is secure SSL and i already use these commands in my contact.php file

ini_set("SMTP","smtp.gmail.com");
ini_set("sendmail_from","<email-address>@gmail.com>");

那么我可以使用什么命令来启用 STARTTLS 或在 php,ini 文件中配置??

so what command i can use to enable STARTTLS or configure in php,ini file??

推荐答案

首先,确保您的 PHP 安装支持 SSL(在 phpinfo() 的输出中查找openssl"部分).

First, make sure you PHP installation has SSL support (look for an "openssl" section in the output from phpinfo()).

您可以在 PHP.ini 中设置以下设置:

You can set the following settings in your PHP.ini:

ini_set("SMTP","ssl://smtp.gmail.com");
ini_set("smtp_port","465");

相关文章