php - 如何在 Codeigniter 中使收件人电子邮件动态化

标签 php mysql codeigniter email

我有一个处理电子邮件的电子邮件 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/

相关文章:

php - PHP 中的 ISO-8601 周编号与 "Outlook"编号

php - sql 查询未从 php 中的对象方法内触发

php - Codeigniter Controller 中的 BootstrapDialog 警报

php - 使用 codeigniter 框架将数据插入数据库不起作用

java - JPA在MySQL数据库中保存错误的日期

mysql - “NOT BETWEEN”在 codeigniter 中不起作用

php - 获取一个条目的多个日期之间的平均时间

php - 在 Twitter Bootstrap 类中使用 "action"

php - 警告 : Division By Zero - Calculating percentages

php - MySQL 中 NOT EXISTS 的替代方案,因为使用 NOT EXISTS 执行查询需要时间