I have a problem that I - sort of - fixed, but I'm curious why it happens.
I'm sending multiple (different) e-mails to multiple users. The template of the e-mail is the same, but every e-mail has some unique data (so bcc is not possible).
This is the code:
function send_email() {
$CI =& get_instance();
$CI->email->clear(TRUE);
$CI->email->from(xx);
$CI->email->to($email);
$CI->email->subject('subject');
// Set the to load email in view, so the template can call this view
$data['view'] = 'email/'.$type.'-html';
$CI->email->message($CI->load->view('email/email-template', $data, TRUE));
$CI->email->send();
}
xx is of course the from e-mail.
I'm calling this function from within a loop, to some e-mails a PDF file is attached.
The problem is that I receive some e-mails twice, and some weird blank e-mails. I fixed this by adding a
sleep(20);
to my code. Does anyone know why this is happening? There is nothing wrong with the loop or the data, I checked this a couple of time and it does work with the sleep function added.