使用codeigniter发送电子邮件时以及打印时出现问题
$this->email->print_debugger();
打印:
“您的邮件已使用以下协议成功发送: 邮件“
但用户在成功发送后无法收到任何电子邮件。
这是发送电子邮件时的代码:
date_default_timezone_set('Asia/Manila');
$this->load->helper('string');
$password= random_string('alnum', 8);
$data = array ('password' => md5($password),
'tag' => 0
);
$this->db->where('emp_id', $user['employee_id']);
$this->db->update('credentials', $data);
$this->load->library('email');
$this->email->from('noreply@company.com', 'company');
//$this->email->reply_to('noreply@company.com');
$this->email->to($user['company_email']);
$this->email->subject('Password reset');
$this->email->message('You have requested a code. Here is your code: '. $password);
$check = $this->email->send();
这是我在配置文件中的代码:
$ci = get_instance();
$ci->load->library('email');
$config['protocol'] = "sendmail";
$config['smtp_host'] = "ssl://mail.company.com";
//$config['smtp_port'] = "465";
$config['smtp_port'] = "25";
//$config['smtp_user'] = "person@company.com";
//$config['smtp_pass'] = "";
$config['charset'] = "utf-8";
$config['mailtype'] = "html";
$config['newline'] = "\r\n";
$config['crlf'] = "\r\n";
$ci->email->initialize($config);
当我们在内部网络时,我可以成功发送电子邮件。但是当我在家里试图发送电子邮件时。代码仍然有效,但用户无法接收电子邮件。先谢谢你们!
答案 0 :(得分:0)
尝试
$config['protocol'] = "http";
或
$config['protocol'] = "smtp";