CodeIgniter Forums
CodeIgniter sends three mails instead of one - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: CodeIgniter sends three mails instead of one (/thread-63420.html)



CodeIgniter sends three mails instead of one - patguitar - 10-28-2015

Hello,


I am using CodeIgniter 3.02 for sending a newsletter. I'm just sending 1 mail to one recipient, but I receive the same mail 3 times.

I don't use a loop. I don't understand why three mails were sent.

My code :

Code:
function sendMailProspects(){
   date_default_timezone_set ("Europe/Berlin");

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

   $config['protocol'] = 'mail';
   $config['charset'] = 'utf-8';
   $config['wordwrap'] = TRUE;
   $config['mailtype'] = 'html';

   $this->email->initialize($config);

   $this->email->to('[email protected]');
   $this->email->from('[email protected]','John DOE');
   $this->email->reply_to('[email protected]', 'John DOE');
   $this->email->subject('Mysubject');
   $this->email->message('<h1>HTML CODE</h1><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Provident.</p>');
   $this->email->set_alt_message('texte');
   $this->email->send();
}

I just execute this method directly in the url, no loop, nothing special.

I've tested this code on localhost and on an shared hosting with the same result: I receive three mails.

What could I be doing wrong?

Thank's

Patrice


RE: CodeIgniter sends three mails instead of one - ignitedcms - 10-28-2015

You must be calling it three times. Either in your controller or somewhere else. Check carefully again. Also disable any plugins you might have on your web browser.

http://stackoverflow.com/questions/13971582/codeigniter-email-send-being-send-twice


RE: CodeIgniter sends three mails instead of one - patguitar - 10-28-2015

Hello,

I resolved the problem. It was the web browser who are the origin of the problem. I don't know realy why, but with this method, there is't duplicat mail.

function index ()
{
self:ConfusedendMailProspects();
redirect('newsletter');
}