有些电子邮件没有发送codeigniter

时间:2018-05-30 19:38:46

标签: php codeigniter gmail email-integration

我正在尝试通过 Codeigniter 电子邮件库发送大量电子邮件。但是,只有前几封电子邮件成功发送。

这是我的Mail_model

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Mail_model extends CI_Model{

    public function __construct(){

        parent::__construct();
        $this->load->library('email');

    }

    public function send_mail($email, $firstname, $data){

        $subject = $data['subject'];
        $message = 'Dear '.$firstname.',<br /><br />'.$data['message'].'<br />'.DOMAIN_NAME;

        //configure email settings
        $config['protocol'] = 'smtp';
        $config['smtp_timeout'] = 5;
        $config['smtp_host'] = SMTP_HOST; //smtp host name
        $config['smtp_port'] = SMTP_PORT; //smtp port number
        $config['smtp_user'] = FROM_EMAIL;
        $config['smtp_pass'] = FROM_PASSWORD; //$from_email password
        $config['mailtype'] = 'html';
        $config['charset'] = 'utf-8';
        $config['wordwrap'] = TRUE;
        $config['newline'] = "\r\n"; //use double quotes
        $config['validation'] = TRUE;
        $this->email->initialize($config);

        //send mail
        $this->email->from(FROM_EMAIL, DOMAIN_NAME);
        $this->email->to($email);
        $this->email->subject($subject);
        $this->email->message($message);

        //echo json_encode($this->email->print_debugger());
        $this->email->send();      

    }//end method send_mail


  }//end class

以下是我的控制器中的一些代码,我从模型中调用send_mail函数

$customers = $this->customer_model->get_customers();

                foreach($customers as $customer){

                    $this->mail_model->send_mail($customer['email'], $customer['firstname'], $this->input->post());
                    sleep(10);

                }

我在循环结束时添加了sleep(10),看看是否一切都能正常运行但是没有帮助。我使用 Gmail

0 个答案:

没有答案