[英]Codeigniter not sending email with smtp settings
我在config文件夾中有email.php:
$config = Array(
'protocol' => 'tls',
'smtp_host' => 'mail.lifepro.ro',
'smtp_port' => 465,
'smtp_user' => 'office@lifepro.ro',
'smtp_pass' => 'xxxxxxxxxxxx',
'mailtype' => 'html',
'charset' => 'utf-8',
'wordwrap' => TRUE
);
而這個功能在助手中
function email_send($to, $subject, $body) {
$ci = get_instance();
$ci->email->from('office@lifepro.ro', 'Office LifePro');
$ci->email->to($to);
$ci->email->cc('office@lifepro.ro');
$ci->email->subject($subject);
$ci->email->message($body);
if($ci->email->send())
return true;
}
問題是即使我輸入了錯誤的憑據,CI也會發送電子郵件。 為什么會這樣呢? 我知道config文件夾中的email.php會自動加載。
在電子郵件庫中您無需執行任何操作,請使用此功能
$this->load->library('email'); //load library
$this->email->from('your@example.com', 'Your Name');
$this->email->to('someone@example.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
if(!$this->email->send())
{
echo $this->email->print_debugger();
}
else
{
echo "Sent"
}
解決了
'protocol' => 'smtp'
$config = Array(
'protocol' => 'smtp',
'smtp_crypto' => 'tls', // <--- notice
'smtp_host' => 'mail.lifepro.ro',
'smtp_port' => 465, // <--- or 587
'smtp_user' => 'office@lifepro.ro',
'smtp_pass' => 'xxxxxxxxxxxx',
'mailtype' => 'html',
'charset' => 'utf-8',
'wordwrap' => TRUE
);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.