[eluser]cdonate[/eluser]
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:
Code: <?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->load->library('email');
$CI->email->set_newline("\r\n");
$CI->email->from('[email protected]','SINUS - 2012');
$CI->email->to($email);
$CI->email->subject($subject);
$CI->email->message($email_body);
if($attach){
$path = $CI->config->item('server_root');
$file = $path. '/inscricao/attachments/Application_SiNUS_TPIR.doc';
$CI->email->attach($file);
}
if($CI->email->send()){
$CI->email->clear();
return TRUE;
}else{
print_r($CI->email->print_debugger());die();
return FALSE;
}
}
}
Even with the Code: $CI->email->clear();
code, if the first email has one attachment all the others carry it too, even if they have
This is my debug code.
Code: function emailteste(){
$this->load->library('my_email');
$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!
[eluser]cdonate[/eluser]
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.
Cheers!
|