我有一个处理电子邮件的电子邮件 Controller 。现在,我想从数据库中读取收件人的邮件。
这是我的代码
//Send email
$this->load->library('email');
$this->load->helper('email');
$this->email->set_mailtype("html");
$FLnames = $this->input->post('firstname')." ".$this->input->post('lastname');
$this->email->from($this->input->post('email'), $FLnames);
$this->email->to('myemail@email.com'); //<-------- I want this to be retrieved from the databse
$this->email->subject('Subject');
我对 CodeIgniter 有点陌生,因此我们将不胜感激任何帮助!
最佳答案
来自documentation ,这是您向多个收件人发送电子邮件的方式:
$list = array('one@example.com', 'two@example.com', 'three@example.com');
$this->email->to($list);
现在要从数据库获取 $list,您可以使用 Codeigniter's Active Record Class ,像这样:
$this->db->select('email_field');
$list = $this->db->get('your_table')->result_array();
关于php - 如何在 Codeigniter 中使收件人电子邮件动态化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20522885/