Welcome Guest, Not a member yet? Register   Sign In
Timeout and newsletter
#3

[eluser]TheFuzzy0ne[/eluser]
Here's a hypothetical controller, which should send the Emails. Obviously, your database would probably have a different schema, and you wouldn't want to call this function via a URI without some other countermeasures to prevent it being called by just anyone. It hasn't been tested, but in theory it should work or at least help point you in the direction that I would take.
Code:
<?php
class Emailer extends Controller {
    
    function Emailer()
    {
        parent::Constructor();
    }
    
    function _get_100_addresses()
    {
        static $start_id = 0;
        
        $this->db->select('id', 'email_address');
        $this->db->from('users');
        $this->db->where('id >', $start_id);
        $this->db->order_by('id', 'asc');
        $this->db->limit(100);

        $res = $this->db->get();
        
        if ($res->num_rows() > 0)
        {
            $arr = array();
            foreach ($res->result_array() as $row)
            {
                $arr[] = $row['email_address'];
                $start_id = $row['id'];
            }
            return implode(',', $arr);
        }
        return FALSE;
    }
    
    function send_emails()
    {
        $this->load->database();
        $this->load->library('email');

        $this->email->from('[email protected]', 'Your Name');
        $this->email->subject('Email Test');
        $this->email->message('Testing the email class.');    

        while ($addresses = $this->_get_100_addresses())
        {
            $this->email->bcc($addresses);
            $this->email->send();
        }
        
        $this->load->view('done');
    }
}


Messages In This Thread
Timeout and newsletter - by El Forum - 02-21-2009, 09:56 AM
Timeout and newsletter - by El Forum - 02-21-2009, 10:13 AM
Timeout and newsletter - by El Forum - 02-21-2009, 10:30 AM



Theme © iAndrew 2016 - Forum software by © MyBB