前一陣子在Codeigniter下使用GMAIL的SMTP(TLS)寄送信件時
Email config設定可參考文章最下方)
發生信件無法寄出的問題,
原因在於Google有阻擋安全性較低的應用程式存取權,
所以必須在Google去將設定更改。

 

處理步驟如下(以下連結或圖片可能會因Google版本更新而失效或呈現方式不同)

#進入Google帳號 “登入和安全性” 設定頁面
google設定頁面

#將頁面移至最下方的 [允許安全性較低的應用程式] 設定

允許安全性較低的應用程式

 

#開啟 [允許安全性較低的應用程式] 

開啟[允許安全性較低的應用程式]

#處理完畢信件應該可以正常寄送。

 

Codeigniter的email config 參考設定為:

$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.gmail.com'; 
$config['smtp_port'] = '587';
$config['smtp_crypto'] = 'tls';
$config['smtp_user'] = 'YOUREMAILID@gmail.com';
$config['smtp_pass'] = 'YOURPASSWORD';
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$config['newline'] = "\r\n"; //use double quotes to comply with RFC 822 standard