Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
根据codeigniter中选定的用户从发送邮件_Codeigniter_Email - Fatal编程技术网

根据codeigniter中选定的用户从发送邮件

根据codeigniter中选定的用户从发送邮件,codeigniter,email,Codeigniter,Email,我的应用程序中有一个选择表单..我从“选择框”下拉列表中的“用户”表中获取用户列表..我正在尝试根据“从”下拉列表中选择的用户发送邮件。。 我从下拉列表中获取了用户id。但我没有收到电子邮件。我尝试了很多次,但没有找到错误的地方 这是我的控制器: 公共函数添加_选择() { 如果($this->input->post()) } 这是我的模型: function get_user_email_by_id($user_id) { } 请帮我怎么做。。 谢谢..在您的模型中。像这样试一次 fu

我的应用程序中有一个选择表单..我从“选择框”下拉列表中的“用户”表中获取用户列表..我正在尝试根据“从”下拉列表中选择的用户发送邮件。。 我从下拉列表中获取了用户id。但我没有收到电子邮件。我尝试了很多次,但没有找到错误的地方

这是我的控制器:

公共函数添加_选择() {

如果($this->input->post())

}

这是我的模型:

 function get_user_email_by_id($user_id) 
{

}

请帮我怎么做。。
谢谢..

在您的模型中。像这样试一次

 function get_user_email_by_id($user_id) 
    {
    $this->db->select('email'); 
    $this->db->from('users'); 
    $this->db->where('user_id',$user_id); 
    $query = $this->db->get(); 
    return $query->row()->email;
    }
鉴于:

<select class="form-control" multiple class="form-control" data-placeholder="user name" name="user_id[]" >
<?php foreach($usertype as $rows) { ?> 
<option value="<?php echo $rows->user_id?>"><?php echo ucfirst($rows->first_name)?></option> 
<?php } ?>


尝试此操作,在多次选择值时,通过选择获取数组中的值!name=“选择[]”

if(计数($this->input->post())>0){
$this->SelectionModel->add_selection_details($this->input->post());
$all_users=$this->input->post('user_id');
打印(所有用户);
foreach($key为所有用户)
{
$get\u email=$this->SelectionModel->get\u user\u email\u by\u id($key);
$config=Array(
'协议'=>'smtp',
'smtp_主机'=>'ssl://md-in-42.webhostbox.net',
“smtp_端口”=>465,
'smtp_用户'=>'test3@clozloop.com',
“smtp_pass”=>“test3”,
“邮件类型”=>“html”,
“字符集”=>“iso-8859-1”,
'wordwrap'=>'TRUE',
“换行符”=>“\r\n”
);
$this->load->library('email',$config);
$this->email->set_mailtype(“html”);
$this->email->from($this)test3@clozloop.com","巴拉提",;
$this->email->to($get_email);
$this->email->subject('这是我们的候选人详细信息,请过目');
$link='单击此链接-';
$this->email->message($link);
打印(获取电子邮件);
如果($this->email->send())
{
回显“已发送电子邮件”;
}
其他的
{
回显“电子邮件失败”;
}
}
}

print(所有用户)上的输出是什么?它显示用户id我正在尝试获取该用户id电子邮件..但它不起作用..id数组还是仅显示一个id?它仅显示一个id..但我希望id数组..并显示在用户预览中..但它不存储在数据库中为单个用户编辑答案。您需要显示视图部分以了解如何在中选择多用户下拉列表。更改
name=“user\u id[]”
。并以与在控制器中尝试相同的方式尝试。@M5533很高兴帮助您。祝您好运。我可以像这样使用$list=array('nalamalapu')。bharathi@gmail.com“巴拉蒂。nalamalapu@gmail.com');$此->电子邮件->收件人($get\u email,$list);
 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'];
 function get_user_email_by_id($user_id) 
    {
    $this->db->select('email'); 
    $this->db->from('users'); 
    $this->db->where('user_id',$user_id); 
    $query = $this->db->get(); 
    return $query->row()->email;
    }
<select class="form-control" multiple class="form-control" data-placeholder="user name" name="user_id[]" >
<?php foreach($usertype as $rows) { ?> 
<option value="<?php echo $rows->user_id?>"><?php echo ucfirst($rows->first_name)?></option> 
<?php } ?>
if(count($this->input->post()) > 0) {

  $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',
          'mailtype' => 'html',
          'charset' => 'iso-8859-1',
          'wordwrap' => 'TRUE',
          'newline' => '\r\n'
      );
         $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";
          }


}
}