简体   繁体   English

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

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

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 and i already use these commands in my contact.php file我正在使用 gmail SMTP 服务器和 gmail 使用安全 SSL 的 STARTTLS 并且我已经在我的 contact.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 文件中进行配置?

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

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

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.ini 文件并通过从Gmail SMTP 设置中获取 ref 填写相应字段中的所有值

Remove comments from the [mail function] Statements which are instructions to the smtp Server and Match their values.从 [mail function] 语句中删除注释,这些语句是对 smtp 服务器的指令并匹配它们的值。

Also the sendmail SMTP server is a Fake server. sendmail SMTP 服务器也是一个假服务器。 Its nothing beside a text terminal (Try writing anything on it. :P).除了文本终端之外什么都没有(尝试在上面写任何东西。:P)。 It will use gmail s,tp to send Mails.它将使用 gmail s,tp 发送邮件。 So configure it correctly by matching Gmail SMTP settings:因此,通过匹配 Gmail SMTP 设置来正确配置它:

smtp.gmail.com
Port: 587

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 应该可以完成这项工作。

//The challenge is with Create the Transport .  Replace the following

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


////With the following lines of codes


         //new Create the Transport
    $transport = (new Swift_SmtpTransport('smtp.googlemail.com', 465, 'ssl'))
      ->setUsername('xxxxxxxxx@gmail.com')
      ->setPassword('xxxxxx');

In my case, Swift Mailer couldn't help either.就我而言,Swift Mailer 也无能为力。 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 );我在这里找到了一个解决方案: http : //forum.powweb.com/showthread.php? stream_socket_enable_crypto( $connection, true, STREAM_CRYPTO_METHOD_TLS_CLIENT ); - 所以在 EHLO 命令之后需要发送 STARTTLS 命令,使用stream_socket_enable_crypto( $connection, true, STREAM_CRYPTO_METHOD_TLS_CLIENT );启用加密stream_socket_enable_crypto( $connection, true, STREAM_CRYPTO_METHOD_TLS_CLIENT ); and again EHLO command.并再次 EHLO 命令。 Only this allowed me to send emails with my "stubborn" SMTP server.只有这样我才能用我“顽固的”SMTP 服务器发送电子邮件。

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]

Out of the box Swift Mailer can't do STARTTLS, however some nice guys have written a patch for it .开箱即用的 Swift Mailer 无法执行 STARTTLS,但是一些好心人已经为它编写了补丁

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我发现修补它有点麻烦(可能以错误的方式进行),因此已将其压缩以供在此处下载: Swift Mailer with STARTTLS

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 the line from并改变了线路

-o smtpd_tls_security_level=encrypt 

to

-o smtpd_tls_security_level=may

And worked on fine并且工作得很好

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

For Windows, I was able to get it working by enabling TLS for secure communication on the SMTP Virtual server.对于 Windows,我能够通过在 SMTP 虚拟服务器上启用 TLS 进行安全通信来使其工作。 TLS will not be available on the SMTP virtual server without a certificate.没有证书的 SMTP 虚拟服务器上将无法使用 TLS。 This link will give the steps needed.此链接将提供所需的步骤。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SMTP 服务器响应:530 5.7.0 必须首先发出 STARTTLS 命令。 Windows 7的 - SMTP server response: 530 5.7.0 Must issue a STARTTLS command first. windows 7 WampServer:警告:mail():SMTP 服务器响应:530 5.7.0 必须先发出 STARTTLS 命令 - WampServer: Warning: mail(): SMTP server response: 530 5.7.0 Must issue a STARTTLS command first php mail函数错误 - &gt;警告:mail()[function.mail]:SMTP服务器响应:530 5.7.0必须先发出STARTTLS命令 - php mail function error -> Warning: mail() [function.mail]: SMTP server response: 530 5.7.0 Must issue a STARTTLS command first SMTP-&gt;错误:服务器未接受AUTH:530 5.7.0必须首先发出STARTTLS命令 - SMTP -> ERROR: AUTH not accepted from server: 530 5.7.0 Must issue a STARTTLS command first 如何解决此错误( mail(): SMTP server response: 530 5.7.0 Must issue a STARTTLS command first. i2sm7399406pjt.19 - gsmtp ) - How solve this error ( mail(): SMTP server response: 530 5.7.0 Must issue a STARTTLS command first. i2sm7399406pjt.19 - gsmtp ) SMTP 错误:MAIL FROM 命令失败:530 5.7.0 使用 PHPMailer 时必须先发出 STARTTLS 命令 - SMTP ERROR: MAIL FROM command failed: 530 5.7.0 Must issue a STARTTLS command first when using PHPMailer PHPMailer:不接受来自服务器的MAIL:530 5.7.0必须首先发出STARTTLS命令 - PHPMailer : MAIL not accepted from server: 530 5.7.0 Must issue a STARTTLS command first 无法发送 AUTH LOGIN 命令。 错误:530 5.7.0 必须先发出 STARTTLS 命令 - Failed to send AUTH LOGIN command. Error: 530 5.7.0 Must issue a STARTTLS command first Symfony SwiftmailerBundle:Gmail 发送“530 5.7.0 必须先发出 STARTTLS 命令” - Symfony SwiftmailerBundle: Gmail sends “530 5.7.0 Must issue a STARTTLS command first” PHP SMTP 错误:SMTP 服务器响应:530 5.7.0 - PHP SMTP ERROR: SMTP server response: 530 5.7.0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM