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

发布于 2024-10-21 11:45:35 字数 358 浏览 1 评论 0原文

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

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

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

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

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

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

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

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>");

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

手心的海 2024-10-28 11:45:35

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

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

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

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

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

ini_set("SMTP","ssl://smtp.gmail.com");
ini_set("smtp_port","465");
你与昨日 2024-10-28 11:45:35

问题解决了,

我编辑了文件 /etc/postfix/master.cf

并评论

-o smtpd_relay_restrictions=permit_sasl_authenticated,reject

并将该行从 改为

-o smtpd_tls_security_level=encrypt 

-o smtpd_tls_security_level=may

工作正常

Problem Solved,

I edited the file /etc/postfix/master.cf

and commented

-o smtpd_relay_restrictions=permit_sasl_authenticated,reject

and changed the line from

-o smtpd_tls_security_level=encrypt 

to

-o smtpd_tls_security_level=may

And worked on fine

太阳公公是暖光 2024-10-28 11:45:35

我知道 PHPMailer 库可以处理这种 SMTP 事务。

另外,带有 sendmail-SSL 库的假 sendmail 应该可以完成这项工作。

I know that PHPMailer library can handle that kind of SMTP transactions.

Also, a fake sendmail with sendmail-SSL library should do the job.

仅一夜美梦 2024-10-28 11:45:35

就我而言,斯威夫特·梅勒也无能为力。我在这里找到了一个解决方案: http://forum.powweb.com/showthread.php?t =73406 - 因此,在 EHLO 命令之后,需要发送 STARTTLS 命令,使用 stream_socket_enable_crypto( $connection, true, STREAM_CRYPTO_METHOD_TLS_CLIENT ); 启用加密,然后再次发送 EHLO 命令。只有这样我才能使用“顽固”的 SMTP 服务器发送电子邮件。

In my case, Swift Mailer couldn't help either. I found a solution here: http://forum.powweb.com/showthread.php?t=73406 - so after EHLO command one needs to send STARTTLS command, enabling cryptography with stream_socket_enable_crypto( $connection, true, STREAM_CRYPTO_METHOD_TLS_CLIENT ); and again EHLO command. Only this allowed me to send emails with my "stubborn" SMTP server.

神魇的王 2024-10-28 11:45:35

开箱即用的 Swift Mailer 无法执行 STARTTLS,但是有些 好人已经为它写了一个补丁

我发现修补它有点麻烦(可能是以错误的方式进行的),因此将其压缩以供下载:带有 STARTTLS 的 Swift Mailer

Out of the box Swift Mailer can't do STARTTLS, however some nice guys have written a patch for it.

I found patching it was a bit of a chore (probably went about it the wrong way), so have zipped it up ready for download here: Swift Mailer with STARTTLS

玻璃人 2024-10-28 11:45:35

我对以下内容有错误的响应:

fputs($connection, 'STARTTLS'.$newLine);

原来我使用了错误的连接变量,所以我只需将其更改为:

fputs($smtpConnect, 'STARTTLS'.$newLine);

如果使用 TLS,请记住在之前和之后放置 HELO:

fputs($smtpConnect, 'HELO '.$localhost . $newLine);
$response = fgets($smtpConnect, 515);
if($secure == 'tls')
{
    fputs($smtpConnect, 'STARTTLS'.$newLine);
    $response = fgets($smtpConnect, 515);
stream_socket_enable_crypto($smtpConnect, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);

// Say hello again!
    fputs($smtpConnect, 'HELO '.$localhost . $newLine);
    $response = fgets($smtpConnect, 515);
}

I had a false response for the following:

fputs($connection, 'STARTTLS'.$newLine);

turns out I use the wrong connection variable, so I just had to change it to:

fputs($smtpConnect, 'STARTTLS'.$newLine);

If using TLS remember to put HELO before and after:

fputs($smtpConnect, 'HELO '.$localhost . $newLine);
$response = fgets($smtpConnect, 515);
if($secure == 'tls')
{
    fputs($smtpConnect, 'STARTTLS'.$newLine);
    $response = fgets($smtpConnect, 515);
stream_socket_enable_crypto($smtpConnect, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);

// Say hello again!
    fputs($smtpConnect, 'HELO '.$localhost . $newLine);
    $response = fgets($smtpConnect, 515);
}
ζ澈沫 2024-10-28 11:45:35

我将分享我的方法,它在实施以下操作后对我有用:

打开 Php.ini 文件并通过从 Gmail SMTP 设置

从[邮件功能]中删除注释smtp 服务器并匹配它们的值。

此外,sendmail SMTP 服务器是一个假服务器。除了文本终端之外什么也没有(尝试在上面写任何东西。:P)。
它将使用 gmail s,tp 发送邮件。
因此,通过匹配 Gmail SMTP 设置来正确配置它:

smtp.gmail.com
Port: 587

I am going to share my way and it worked for me after implementing following:

Open Php.ini file and fill the all the values in the respective fields by taking ref from Gmail SMTP Settings

Remove comments from the [mail function] Statements which are instructions to the smtp Server and Match their values.

Also the sendmail SMTP server is a Fake server. Its nothing beside a text terminal (Try writing anything on it. :P).
It will use gmail s,tp to send Mails.
So configure it correctly by matching Gmail SMTP settings:

smtp.gmail.com
Port: 587
烂人 2024-10-28 11:45:35
//The challenge is with Create the Transport .  Replace the following

 $transport = (new Swift_SmtpTransport('smtp.gmail.com', 587))
        ->setUsername('[email protected]')
        ->setPassword('xxxxxxxxx');


////With the following lines of codes


         //new Create the Transport
    $transport = (new Swift_SmtpTransport('smtp.googlemail.com', 465, 'ssl'))
      ->setUsername('[email protected]')
      ->setPassword('xxxxxx');
//The challenge is with Create the Transport .  Replace the following

 $transport = (new Swift_SmtpTransport('smtp.gmail.com', 587))
        ->setUsername('[email protected]')
        ->setPassword('xxxxxxxxx');


////With the following lines of codes


         //new Create the Transport
    $transport = (new Swift_SmtpTransport('smtp.googlemail.com', 465, 'ssl'))
      ->setUsername('[email protected]')
      ->setPassword('xxxxxx');
猫烠⑼条掵仅有一顆心 2024-10-28 11:45:35

我遇到了同样的问题,我找到的解决方案是添加以下内容:

sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t" in the [mail function]

I had the same problem and the solution I found was to add this:

sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t" in the [mail function]
夏日落 2024-10-28 11:45:35

块引用

I then modified the php.ini file to use it (commented out the other lines):

[mail function]
; For Win32 only.
; SMTP = smtp.gmail.com
; smtp_port = 25

; For Win32 only.
; sendmail_from = <e-mail username>@gmail.com

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = "C:\xampp\sendmail\sendmail.exe -t"

Ignore the "For Unix only" comment, as this version of sendmail works for Windows.

You then have to configure the "sendmail.ini" file in the directory where sendmail was installed:

[sendmail]

smtp_server=smtp.gmail.com
smtp_port=25
error_logfile=error.log
debug_logfile=debug.log
auth_username=<username>
auth_password=<password>
force_sender=<e-mail username>@gmail.com

http://byitcurious.blogspot.com.br/2009/04/solving-must-issue-starttls-command.html

> Blockquote

Blockquote

I then modified the php.ini file to use it (commented out the other lines):

[mail function]
; For Win32 only.
; SMTP = smtp.gmail.com
; smtp_port = 25

; For Win32 only.
; sendmail_from = <e-mail username>@gmail.com

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = "C:\xampp\sendmail\sendmail.exe -t"

Ignore the "For Unix only" comment, as this version of sendmail works for Windows.

You then have to configure the "sendmail.ini" file in the directory where sendmail was installed:

[sendmail]

smtp_server=smtp.gmail.com
smtp_port=25
error_logfile=error.log
debug_logfile=debug.log
auth_username=<username>
auth_password=<password>
force_sender=<e-mail username>@gmail.com

http://byitcurious.blogspot.com.br/2009/04/solving-must-issue-starttls-command.html

> Blockquote
—━☆沉默づ 2024-10-28 11:45:35

对于 Windows,我可以通过在 SMTP 虚拟服务器上启用 TLS 进行安全通信来使其正常工作。如果没有证书,TLS 将无法在 SMTP 虚拟服务器上使用。此链接将提供所需的步骤。

https: //support.microsoft.com/en-ie/help/4014125/how-to-configure-iis-smtp-for-outgoing-tls-authentication

For Windows, I was able to get it working by enabling TLS for secure communication on the SMTP Virtual server. TLS will not be available on the SMTP virtual server without a certificate. This link will give the steps needed.

https://support.microsoft.com/en-ie/help/4014125/how-to-configure-iis-smtp-for-outgoing-tls-authentication

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文