Search code examples
codeigniteremail

codeigniter email->send being send twice


i am using codeigniter 2 with the tank_auth library. in the model named user_model it has an function (_send_email()) to send an email:

function _send_email($type, $email, &$data)
{
    $this->load->library('email');
    $this->config->set_item('language', 'dutch'); 

    $this->email->set_newline("\r\n");
    $this->email->from($this->config->item('webmaster_email', 'tank_auth'), $this->config->item('website_name', 'tank_auth'));
    //$this->email->reply_to($this->config->item('webmaster_email', 'tank_auth'), $this->config->item('website_name', 'tank_auth'));
    $this->email->to($email);
    $this->email->subject(sprintf($this->lang->line('auth_subject_'.$type), $this->config->item('website_name', 'tank_auth')));
    $this->email->message($this->load->view('email/'.$type.'-html', $data, TRUE));
    $this->email->set_alt_message($this->load->view('email/'.$type.'-txt', $data, TRUE));

    if($this->email->send()){
        echo "sendit";
    }
}

i try to call this function from a controller like this:

public function email($value='')
{
    $this->lang->load('tank_auth', 'dutch');
    $this->load->model('user_model');
    $data = array("site_name" => "site name");
    $this->user_model->_send_email('bestelling_geplaatst', "[email protected]",$data); // send 
}

the problem is that the email is being sent twice to the email adres

anyone who run across this problem an know's where to look for an solution ( or the problem)

More info:

i am trying to make a method in my controller just like the example in the use guide like here: https://www.codeigniter.com/user_guide/libraries/email.html

    $this->load->library('email');

$this->email->from('[email protected]', 'Your Name');
$this->email->to('[email protected]'); 
$this->email->cc('[email protected]'); 
$this->email->bcc('[email protected]'); 

$this->email->subject('Email Test');
$this->email->message('Testing the email class.');  

$this->email->send();

This method also sends the email twice!


Solution

  • The reason is i have the plugin Firebug Lite for Google Chrome. after i deactivated this the page only requested once! found awnser right here: https://stackoverflow.com/a/10580841/1108772

    Thanks everyone for replying and all you help