I got the same problem. Adding TRUE in clear solved the issue for me.
$this->email->clear(TRUE);
Codeigniter: Email attachment of last emails not cleared while sending multiple emails in loop
Pregunta
I am using the Codeigniter email class and sending automated emails when an invoice is created or something. I get the emails perfect fine on Gmail, no duplicate attachments but my clients who are using Exchange and Outlook are getting up to 3 duplicates of one file on the emails. Here is the relevant PHP code (however I do not think it is a code issue)
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'smtp.1and1.com',
'smtp_port' => 25,
//'smtp_crypto' => 'ssl',
'smtp_user' =>'user@mywebsite.com',
'smtp_pass' => 'password',
'mailtype' => 'html',
'charset' => 'utf-8'
);
$this->load->library('email', $config);
$this->email->clear();
$this->email->set_newline("\r\n");
$this->email->set_crlf( "\r\n" );
$this->email->from('user@mywebsite', 'UserName');
$this->email->to($email);
$this->email->subject($subject);
$this->email->message($msg);
$this->email->attach($attachment);
$this->email->send();
Any thoughts on why this might be occurring? I think it has something to do with the Outlook and Exchange server as I never get duplicates on my Gmail account
Thank you for looking
Solución
I got the same problem. Adding TRUE in clear solved the issue for me.
$this->email->clear(TRUE);
Codeigniter: Email attachment of last emails not cleared while sending multiple emails in loop
Otros consejos
What is $this? PHPMailer? A home grown lib? Something else?
Are you possibly looping through a list of addresses and maybe not creating a new message? (so email->attach is happening multiple times)?
Just guessing here.