[英]php mail function error -> Warning: mail() [function.mail]: SMTP server response: 530 5.7.0 Must issue a STARTTLS command first
I am trying to send email from php to a gmail account. 我正在尝试从php发送电子邮件到Gmail帐户。 I have the following settings on my laptop:
我的笔记本电脑上有以下设置:
- Windows 8
Windows 8
- Internet connection
网络连接
- XAMPP 1.7.4, PHP Version 5.3.5,
XAMPP 1.7.4,PHP版本5.3.5,
I have the following php.ini settings 我有以下php.ini设置
[mail function] ;
[邮件功能]; For Win32 only.
仅适用于Win32。 ;
; http://php.net/smtp SMTP = smtp.gmail.com ;
http://php.net/smtp SMTP = smtp.gmail.com; http://php.net/smtp-port
http://php.net/smtp-port
smtp_port = :465
smtp_port =:465
;
; For Win32 only.
仅适用于Win32。 ;
; http://php.net/sendmail-from ;sendmail_from = postmaster@localhost
http://php.net/sendmail-from ; sendmail_from = postmaster @ localhost
;
; For Unix only.
仅适用于Unix。 You may supply arguments as well (default: "sendmail -t -i").
您也可以提供参数(默认值:“sendmail -t -i”)。 ;
; http://php.net/sendmail-path ;sendmail_path = "\\"C:\\xampp\\sendmail\\sendmail.exe\\" -t"
http://php.net/sendmail-path ; sendmail_path =“\\”C:\\ xampp \\ sendmail \\ sendmail.exe \\“ - t”
The following is the php code: 以下是php代码:
<?php
$to = 'goodmandiamont@gmail.com';
$subject = 'hi';
$msg = 'Test';
$headers = 'From: postmaster@localhost' ."\r\n" .
'Reply-To: shawn.danisa@gmail.com' . "\r\n" .
'X-Mailer: PHP /' . phpversion();
mail($to, $subject,$msg,$headers);
?>
I get the following error: 我收到以下错误:
Warning: mail() [function.mail]: SMTP server response: 530 5.7.0 Must issue a STARTTLS command first.
警告:mail()[function.mail]:SMTP服务器响应:530 5.7.0必须先发出STARTTLS命令。
I also made sure the IMAP setting is enabled on the gmail settings. 我还确保在gmail设置上启用了IMAP设置。 I also checked to see If I will find the following lines on the php.ini file:
我还检查了如果我将在php.ini文件中找到以下行:
ini_set("SMTP","ssl://smtp.gmail.com");
的ini_set( “SMTP”, “SSL://smtp.gmail.com”);
ini_set("smtp_port","465");
的ini_set( “SMTP_PORT”, “465”);
But no luck, I just cant find them anywhere. 但没有运气,我只是无法在任何地方找到它们。 Please assist, I am new to php.
请协助,我是php的新手。
Initially, you make sure your PHP installation has SSL support (look for an "openssl" section in the output from phpinfo()
). 最初,确保您的PHP安装具有SSL支持(在
phpinfo()
的输出中查找“openssl”部分)。
Again you need to set the following settings in your PHP configuration PHP.ini 您需要在PHP配置PHP.ini中设置以下设置
ini_set("SMTP","ssl://smtp.gmail.com");
ini_set("smtp_port","465");
Hope this solves your problem. 希望这能解决你的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.