php SMTP 服务器响应:530 5.7.0 必须先发出 STARTTLS 命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5265692/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SMTP server response: 530 5.7.0 Must issue a STARTTLS command first
提问by Waqas Ahmed
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 文件中配置?
采纳答案by chuckx
First, make sure you PHP installation has SSL support (look for an "openssl" section in the output from phpinfo()
).
首先,确保您的 PHP 安装支持 SSL(在 输出中查找“openssl”部分phpinfo()
)。
You can set the following settings in your PHP.ini:
您可以在 PHP.ini 中设置以下设置:
ini_set("SMTP","ssl://smtp.gmail.com");
ini_set("smtp_port","465");
回答by boryn
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.
就我而言,Swift Mailer 也无能为力。我在这里找到了一个解决方案:http: //forum.powweb.com/showthread.php?t=73406- 所以在 EHLO 命令之后,需要发送 STARTTLS 命令,使用stream_socket_enable_crypto( $connection, true, STREAM_CRYPTO_METHOD_TLS_CLIENT );
EHLO 命令再次启用加密。只有这样我才能用我“顽固的”SMTP 服务器发送电子邮件。
回答by Richard Williams
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
回答by Frank Forte
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);
}
回答by Alfabravo
回答by Sudhir Singh
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. 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
回答by Hamisi Jabe
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
并且工作得很好
回答by Luis D
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
回答by Jean-Pierre Welch
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,我能够通过在 SMTP 虚拟服务器上启用 TLS 进行安全通信来使其工作。没有证书的 SMTP 虚拟服务器上将无法使用 TLS。此链接将提供所需的步骤。