如何在php中发送电子邮件时附加图像

时间:2015-10-24 14:00:10

标签: php codeigniter email

当我通过我的项目发送图片时,我正在尝试将图片附加到我的电子邮件中...到目前为止,我已成功发送以下代码中的电子邮件。我应该使用哪些更改添加附件对此(添加图像)...请帮我改变我的代码。我正在使用cordelgniter

 public function sendMailToComplete($ID) {
        $this->load->model('get_db');
        $customers = $this->get_db->getBirthdays();
        $this->get_db->updateGreetingStatus();
        if (empty($customers)) {
            return;
        }
        foreach ($this->get_db->getEmailConfig() as $row) {
            $config = array(
                'protocol' => $row->protocol,
                'smtp_host' => $row->host,
                'smtp_user' => $row->user,
                'smtp_pass' => $row->pass,
                'smtp_port' => $row->port,
                'smtp_timeout' => $row->timeout,
                'mailtype' => $row->mailtype,
                'charset' => $row->charset
            );
            $this->load->library('email', $config);

            foreach ($customers as $customer) {
                $email = $customer['email'];

                $this->email->clear();
                $this->email->set_newline("\r\n");
                $this->email->from($row->from, 'ABC');
                $this->email->to($email);
                $this->email->subject('Birthday Greetings');
                $this->email->message('Many Happy Returns of the day...');
                $this->email->send();
            }

            $this->email->clear();
        }
    }
 function getBirthdays()
        {
            $query = $this->db->query("select ci.* from customer_info ci where month(b_day) = month(curdate()) and day(b_day) = day(curdate());");
            return $query->result_array();
        }

1 个答案:

答案 0 :(得分:0)

您应该查看PHPMailer库

示例

querySelector

https://github.com/PHPMailer/PHPMailer

相关问题