CodeIgniter Forums

Full Version: Problem sending multiple e-mails - Attch carries from one e-mail to the next
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

Hi guys!

I'm trying to send multiple e-mails and I'm having problems with my attachment files.

This is my email class, inside the library folder:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class My_email{

public function sendEmail($nome,$sobrenome,$email,$subject,$body,$newPass = NULL, $attach = FALSE){
   $CI =& get_instance();
   $email_data['name'] = $nome;
   $email_data['lastname'] = $sobrenome;
   $email_data['email'] = $email;
   $hash = md5($nome.$sobrenome.$email);
   $email_data['hash'] = $hash;
   $email_data['pass'] = $newPass;
   $email_body = $CI->load->view($body, $email_data, true);
   $CI->email->from('[email protected]','SINUS - 2012');
    $path = $CI->config->item('server_root');
    $file = $path. '/inscricao/attachments/Application_SiNUS_TPIR.doc';
    return TRUE;
   return FALSE;

Even with the
code, if the first email has one attachment all the others carry it too, even if they have
$attach = FALSE

This is my debug code.
function emailteste(){

$this->my_email->sendEmail('Cláudio', 'de Paula Dônaté', '[email protected]','ACTV','email_actv');
$this->my_email->sendEmail('Cláudio', 'de Paula Dônaté', '[email protected]','CONF TPIR','email_conf_TPIR','',TRUE);
$this->my_email->sendEmail('Cláudio', 'de Paula Dônaté', '[email protected]','email_boleto','email_boleto');
$this->my_email->sendEmail('Cláudio', 'de Paula Dônaté', '[email protected]','email_conf_AC_CIJ','email_conf_AC_CIJ');
$this->my_email->sendEmail('Cláudio', 'de Paula Dônaté', '[email protected]','email_final_AC','email_final_AC');
$this->my_email->sendEmail('Cláudio', 'de Paula Dônaté', '[email protected]','email_final_CIJ','email_final_CIJ');
$this->my_email->sendEmail('Cláudio', 'de Paula Dônaté', '[email protected]','email_final_TPIR_ADVOGADO','email_final_TPIR_ADVOGADO');
$this->my_email->sendEmail('Cláudio', 'de Paula Dônaté', '[email protected]','email_final_TPIR_JUIZ','email_final_TPIR_JUIZ');
$this->my_email->sendEmail('Cláudio', 'de Paula Dônaté', '[email protected]','email_newPass','email_newPass');


I was having problems with non english characters, the code above was just for debugging purposes.

Can anyone tell me how to avoid this attachment problem.

On my code there is times that I send multiple e-mails, in a loop, and this problem can be serous.

Thanks guys!

El Forum


If you set the parameter to TRUE any attachments will be cleared as well:

El Forum

Uau, thanks man.

Maybe is the time, 2h40am here in Brazil, but I did not seen this information when I read the user guide.

Sorry for the question.