email attachments |
Hi.
Using the emails library to send attachments, I was getting an issue in a loop of sending emails to recipients, the number of attachments increased to each recipient. It turns out that the $_attachments private array is not cleared unless the $this->email->clear(TRUE) is explicitly called. I can sort of see the reason for this, but in the $this->email->send method, the $this->email->clear(); is used, so attachments are not cleared after sending. I would suggest this is the wrong way around ... if you want attachments to persist across emails, then explicitly set that. Otherwise send the email and assume the _attachments array is going to be cleared for the next iteration. I liken this to the way queries work, after get() is called the query is lost unless I set query caching on. You could amend the code to change the clear method code to automatically wipe attachments. I don't want to change the CI source, so as a work around I am just explicitly calling $this->email->clear(TRUE); after the email is sent. Regards Pete
Probably not going to happen, since it's been that way for years, and changing it now could break a lot of people's websites. What you can do is create an extension, called libraries/MY_Email.php, and change the Email class to better suit your desires. See the documentation for extending libraries.
|
Welcome Guest, Not a member yet? Register Sign In |