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

时间:2021-09-14 18:11:04

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

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

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

当我在php脚本文件中使用mail()函数时,我得到了这个错误消息。

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

我使用STARTTLS使用gmail SMTP服务器和gmail来防止spams,我已经在我的联系人中使用了这些命令。php文件

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??

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

10 个解决方案

#1


13  

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

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

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

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

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

#2


0  

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

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

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

另外,使用sendmail- ssl库的假sendmail应该可以完成这项工作。

#3


0  

Swift Mailer is an excellent PHP mail library that supports SSL/TLS SMTP out of the box. Consider using it in place of the error-prone mail function.

Swift Mailer是一个优秀的PHP邮件库,支持SSL/TLS SMTP。考虑使用它代替容易出错的邮件功能。

#4


0  

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.

在我的例子中,斯威夫特也没办法。我在这里找到了一个解决方案:http://forum.powweb.com/showthread.php?因此,在EHLO命令之后,需要发送STARTTLS命令,使密码学与stream_socket_enable_crypto($connection, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)连接在一起;再一次EHLO命令。只有这样,我才可以用“顽固”的SMTP服务器发送邮件。

#5


0  

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

我发现修补它有点烦人(可能是用错误的方式),所以把它压缩到可以下载的地方:快速邮件发送者和STARTTLS。

#6


0  

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:

如果使用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);
}

#7


0  

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

打开Php。通过从Gmail SMTP设置中获取ref文件并填充相应字段中的所有值。

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

删除[邮件功能]语句中的注释,这些语句是对smtp服务器的指令,并匹配它们的值。

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:

另外,sendmail SMTP服务器是一个假服务器。它与文本终端无关(尝试在它上面写任何东西)。:P)。它将使用gmail s,tp发送邮件。因此,通过匹配Gmail SMTP设置正确地配置它:

smtp.gmail.com
Port: 587

#8


-1  

Problem Solved,

问题解决了,

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

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

and commented

和评论

-o smtpd_relay_restrictions=permit_sasl_authenticated,reject

and changed

和改变

-o smtpd_tls_security_level=encrypt to

-o smtpd_tls_security_level=may

And worked on fine

在细

#9


-1  

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

#10


-2  

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.

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

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

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

#1


13  

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

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

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

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

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

#2


0  

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

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

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

另外,使用sendmail- ssl库的假sendmail应该可以完成这项工作。

#3


0  

Swift Mailer is an excellent PHP mail library that supports SSL/TLS SMTP out of the box. Consider using it in place of the error-prone mail function.

Swift Mailer是一个优秀的PHP邮件库,支持SSL/TLS SMTP。考虑使用它代替容易出错的邮件功能。

#4


0  

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.

在我的例子中,斯威夫特也没办法。我在这里找到了一个解决方案:http://forum.powweb.com/showthread.php?因此,在EHLO命令之后,需要发送STARTTLS命令,使密码学与stream_socket_enable_crypto($connection, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)连接在一起;再一次EHLO命令。只有这样,我才可以用“顽固”的SMTP服务器发送邮件。

#5


0  

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

我发现修补它有点烦人(可能是用错误的方式),所以把它压缩到可以下载的地方:快速邮件发送者和STARTTLS。

#6


0  

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:

如果使用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);
}

#7


0  

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

打开Php。通过从Gmail SMTP设置中获取ref文件并填充相应字段中的所有值。

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

删除[邮件功能]语句中的注释,这些语句是对smtp服务器的指令,并匹配它们的值。

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:

另外,sendmail SMTP服务器是一个假服务器。它与文本终端无关(尝试在它上面写任何东西)。:P)。它将使用gmail s,tp发送邮件。因此,通过匹配Gmail SMTP设置正确地配置它:

smtp.gmail.com
Port: 587

#8


-1  

Problem Solved,

问题解决了,

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

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

and commented

和评论

-o smtpd_relay_restrictions=permit_sasl_authenticated,reject

and changed

和改变

-o smtpd_tls_security_level=encrypt to

-o smtpd_tls_security_level=may

And worked on fine

在细

#9


-1  

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

#10


-2  

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.

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

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

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