[英]Send Email Using CodeIgniter 3.1.10
我想使用codeigniter發送電子郵件,我知道如何在互聯網上做到這一點。 但是當我編寫代碼時,電子郵件不會發送給人們。
使用codeigniter 3.1.10
private function _sendEmail(){
$config = [
'mailtype' => 'html',
'charset' => 'utf-8',
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.gmail.com',
'smtp_user' => '****',
'smtp_pass' => '****',
'smtp_port' => 465,
'crlf' => "\r\n"
];
$this->load->library('email',$config);
$this->email->from('vcopadangpariaman@gmail.com','VCO Padang Pariaman');
$this->email->to('taufikleon44@gmail.com');
$this->email->subject('Testing');
$this->email->message("hallo");
if($this->email->send()){
return true;
}else {
echo $this->email->print_debugger();
}
}
我想發送電子郵件至taufikleon44@gmail.com
可能是由於SMTP驗證中提供的用戶名和密碼錯誤或郵件服務器防火牆中阻止了SMTP端口。
如果您使用的是Gmail帳戶,請檢查此鏈接並關閉“允許安全性較低的應用程序”。
網址如下: https : //myaccount.google.com/lesssecureapps
然后嘗試再次發送電子郵件。
我已經更新了您的代碼並立即檢查:
private function _sendEmail() {
$config = [
'mailtype' => 'html',
'charset' => 'utf-8',
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.gmail.com',
'smtp_user' => '****',
'smtp_pass' => '****',
'smtp_port' => '465',
'smtp_timeout' => '20',
'validation' => TRUE,
'newline' => "\r\n"
];
$this->load->library('email', $config);
$this->email->initialize($config);
$this->email->from('vcopadangpariaman@gmail.com', 'VCO Padang Pariaman');
$this->email->to('taufikleon44@gmail.com');
$this->email->subject('Testing');
$this->email->message("hallo");
if ($this->email->send()) {
return true;
} else {
echo $this->email->print_debugger();
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.