电子邮件不使用Codelgniter发送



我想向管理员验证的用户发送电子邮件。当管理员单击数据库中的验证按钮时,用户的状态会更改,并且电子邮件会发送给用户,状态可能会更改,但电子邮件不会发送。

管理员控制器:

if($this->AdminModel->updateUser($id , $status)){
$user_message = "hello";
$this->load->library('email');
$config['protocol']    = 'smtp';
$config['smtp_host']    = 'ssl://smtp.gmail.com';
$config['smtp_port']    = '465';
$config['smtp_timeout'] = '7';
$config['smtp_user']    = 'kshahroz699@gmail.com';
$config['smtp_pass']    = 'password';
$config['charset']    = 'utf-8';
$config['newline']    = "rn";
$config['mailtype'] = 'text'; // or html
$config['validation'] = TRUE;
$this->email->initialize($config);
$this->email->from('kshahroz699@gmail.com', 'Model Hunt Inquiry');
$this->email->to($email);
$this->email->subject('Model Hunt Inquiry Form');
$this->email->message($user_message);
if($this->email->send()) {
echo " Successfully send";
}else{
echo "Not Send";
}

管理员模型:

function updateUser($id, $data){
$this->db->where('id',$id);
return $this->db->update('mh_users',$data);
}

路线:

$route['verifyUserEmail/(:any)/(:any)'] = 'Admin/verifyEmail/$1/$2';

管理模型

function updateUser($id, $data){
$this->db->where('id',$id);
return $this->db->update('mh_users',$data);
}

我的控制器

$this->load->library('email'); 
if($this->AdminModel->updateUser($id , $status)){
$from   =   'no-reply@test.com';
$to = 'test@gmail.com';
$message1 = 'Hello Test';
$config = array();
$config['useragent'] = "CodeIgniter";
$config['mailpath'] = "/usr/bin/sendmail"; // or "/usr/sbin/sendmail"
$config['protocol'] = "smtp";
$config['smtp_host'] = "localhost";
$config['smtp_port'] = "25";
$config['mailtype'] = 'html';
$config['charset']  = 'utf-8';
$config['newline']  = "rn";
$config['wordwrap'] = TRUE;
$this->email->initialize($config);
$this->email->set_newline("rn");
$this->email->from($from, 'Test');
$this->email->to($to);
$this->email->subject('Test');
$this->email->message($message1);
$this->email->set_mailtype('html');
if($this->email->send()){
$message=array("1","Mail Sent Successfully");
}else{
$message=array("0",$this->db->_error_message());
}
}
$this->session->set_flashdata('message', $message);

相关内容

  • 没有找到相关文章

最新更新