使用wamp server
发送电子邮件时遇到问题。我收到此错误:
220 smtp.gmail.com ESMTP s10sm40910411wjp.3 - gsmtp
hello: 250-smtp.gmail.com at your service, [151.232.116.37]
250-SIZE 35882577
250-8BITMIME
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
Failed to send AUTH LOGIN command. Error: 530 5.7.0 Must issue a STARTTLS command first. s10sm40910411wjp.3 - gsmtp
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
这是codeigniter contoller
:
class SendEmail extends CI_Controller{
public function index(){
$config=array();
$config['protocol' ] = 'smtp' ;
$config['smtp_host'] = 'smtp.gmail.com' ;
$config['smtp_port'] = 465 ;
$config['smtp_user'] = 'test@gmail.com' ;
$config['smtp_pass'] = 'pass' ;
$config['charset' ] = 'utf-8' ;
$config['wordwrap' ] = TRUE ;
$config['validate'] = TRUE ;
$config['_smtp_auth'] = TRUE ;
$config['smtp_crypto'] = 'ssl' ;
$this->load->library('email');
$this->email->initialize($config);
$this->email->from('mytest@gmail.com', 'test');
$this->email->to('mytest@gmail.com');
$this->email->subject("This is Another Email test mail");
$this->email->message("This is email is test for you mr me!the god is more than...");
if($this->email->send()){
echo 'You Are Luck!';
}
else{
echo $this->email->print_debugger();
}
}
现在我不知道问题出在gmail或我的wamp localhost
上,这是wamp服务器php.ini
和sendmail.ini
的配置(我下载了sendmail.zip文件并将其解压缩到wamp64 \ sendmail)。这是我的php.ini
和sendmail.ini
配置
php.ini file:
smtp_port = 465
sendmail_path = "\ "D:\wamp64\sendmail\sendmail.exe\" -t"
和
sendmail.ini file:
auth_username=test@gmail.com
auth_password=test
smtp_server= smtp.gmail.com
smtp_port= 465
答案 0 :(得分:1)
您可能忘记启用IMAP(也允许SMTP)访问您的Gmail帐户。
答案 1 :(得分:0)
Google可能会阻止某些不使用现代安全标准的应用或设备的登录尝试。
更改安全性较低的应用的帐户访问权限: https://www.google.com/settings/security/lesssecureapps