Welcome Guest, Not a member yet? Register   Sign In
Send email automatically with Code Igniter
#1

[eluser]jimmy90[/eluser]
Hi,

I'm very newbie with Code Igniter.

I want to create a code for sending email automatically if the car's speed exceeds the speed limit is in the database.

Here is my code,

Code:
<?php
class Send extends Controller{

    function Send(){
        parent::Controller();
        $this->load->model('Send_model', '', TRUE);
    }
    
    function send_email(){
        $getmail = $this->Send_model->get_mail();
        $getname = $this->Send_model->get_name();
        $getspeed = $this->Send_model->get_speed();
        $getspeedlimit = $this->Send_model->get_speedlimit();
        
        if($getspeed > $getspeedlimit){
            $this->load->library('email', $config);
            $this->email->set_newline("\r\n");
        
            $this->email->from($getmail, $getname);
            $this->email->to('[email protected]');
            
            $this->email->subject('KuLacak');
            $this->email->message('Attention : Speed Alert!!!');
        
            if($this->email->send()){
                echo 'Your email was sent.';
            }
            else{
                $this->email->print_debugger();
            }
        }
    }
}

Code:
<?php
class Send_model extends Model{

    function Send_model(){
        parent::Model();
    }
    
    function get_email(){
        $this->db->select('users.email');
        $this->db->from('users');
        $this->db->where('units.owner = users.id');
        $this->db->where('speed_limit.unit_id = units.id');
        return $this->db->get();
    }
    
    function get_name(){
        $this->db->select('users.username');
        $this->db->from('users');
        $this->db->where('units.owner = users.id');
        $this->db->where('speed_limit.unit_id = units.id');
        return $this->db->get();
    }
    
    function get_speed(){
        $this->db->select('tracks.speed');
        $this->db->from('tracks');
        return $this->db->get();
    }
    
    function get_speedlimit(){
        $this->db->select('speed_limit.batas');
        $this->db->from('speed_limit');
        return $this->db->get();
    }
}

Sorry for my bad english. Thank you.

^^


Messages In This Thread
Send email automatically with Code Igniter - by El Forum - 06-01-2010, 12:35 AM
Send email automatically with Code Igniter - by El Forum - 06-01-2010, 09:44 PM
Send email automatically with Code Igniter - by El Forum - 06-02-2010, 12:59 AM
Send email automatically with Code Igniter - by El Forum - 06-02-2010, 07:22 AM
Send email automatically with Code Igniter - by El Forum - 06-02-2010, 08:46 PM
Send email automatically with Code Igniter - by El Forum - 06-02-2010, 09:01 PM
Send email automatically with Code Igniter - by El Forum - 06-02-2010, 10:20 PM
Send email automatically with Code Igniter - by El Forum - 06-03-2010, 02:35 AM
Send email automatically with Code Igniter - by El Forum - 06-09-2010, 09:14 PM
Send email automatically with Code Igniter - by El Forum - 06-10-2010, 02:06 AM
Send email automatically with Code Igniter - by El Forum - 08-09-2010, 12:32 AM



Theme © iAndrew 2016 - Forum software by © MyBB