sending mail using gmail , codeigniter ,wamp localhost

↘锁芯ラ 提交于 2019-12-08 06:45:57

问题


I have problem to send email using wamp server.I got this error:

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.

And this is 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();
    }
}

Now I don't know that the problem is by gmail or my wamp localhost and this is config of wamp server php.ini and sendmail.ini (I download
sendmail.zip file and extract it into to the wamp64\sendmail).It is my php.ini and sendmail.ini config

php.ini file:
smtp_port = 465
sendmail_path = "\ "D:\wamp64\sendmail\sendmail.exe\" -t"

And

sendmail.ini file:
auth_username=test@gmail.com
auth_password=test
smtp_server= smtp.gmail.com
smtp_port= 465

回答1:


You might have forgotten to enable IMAP (which also enables SMTP) access to your Gmail account.




回答2:


Google may block sign-in attempts from some apps or devices that do not use modern security standards.

Change account access for less secure apps : https://www.google.com/settings/security/lesssecureapps



来源:https://stackoverflow.com/questions/36624376/sending-mail-using-gmail-codeigniter-wamp-localhost

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!