【发布时间】:2017-02-15 05:28:13
【问题描述】:
我的应用程序中有一个选择表单..我从选择框下拉列表中的用户表中获取用户列表..我正在尝试根据下拉列表中选择的用户发送邮件.. 我从下拉列表中获得了 user_id..但我没有收到电子邮件..我尝试了很多,但我没有找到错误的地方..
这是我的控制器:
公共函数 add_selection() {
$data["msg"]="";
$this->load->model('SelectionModel');
$data['rolename']=$this->SelectionModel->getrolename();
$data['candidate']=$this->SelectionModel->getcandidates();
$data['usertype']=$this->SelectionModel->getusers();
if($this->input->post())
{
$this->SelectionModel->add_selection_details($this->input->post());
$all_users = $this->input->post('user_id');
print_r($all_users);
foreach($all_users as $key)
{
$get_email = $this->SelectionModel->get_user_email_by_id($key);
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://md-in-42.webhostbox.net',
'smtp_port' => 465,
'smtp_user' => 'test3@clozloop.com',
'smtp_pass' => 'test3'
);
$this->load->library('email',$config);
$this->email->set_mailtype("html");
$this->email->from('test3@clozloop.com', 'bharathi');
$this->email->to($get_email);
$this->email->subject('this is our candidate details pls go through it');
$link = 'Click on this link - <a href="http://localhost/job_portal/index.php/Login/signin">Click Here</a>';
$this->email->message($link);
print_r($get_email);
if($this->email->send())
{
echo "email sent";
}
else
{
echo "email failed";
}
}
}
$this->load->view('selection/selection_details',$data);
}
这是我的模型:
function get_user_email_by_id($user_id)
{
$this->db->select('*');
$this->db->from('users');
$this->db->where('user_id',$user_id);
$query = $this->db->get();
$result = $query->row_array();
return $result['email'];
}
请帮助我如何做到这一点.. 谢谢。。
【问题讨论】:
-
`print_r($all_users);' 上的输出是什么?
-
显示user_id
-
我正在尝试获取该 user_id 电子邮件..但它不起作用..
-
id 数组还是只有一个 id?
-
它只显示一个 id..但我想要 id 的数组..它显示在用户预览中..但它没有存储在数据库中
标签: codeigniter email