email->attach() attaching file twice |
[eluser]ImageSmith[/eluser]
Well this is a bit of a doozie. I'm sure it is a simple fix but I'm not seeing it right now :ohh: I am generating 2 emails as a result of a form submission (validated, etc). One email to the client, one to the site owner / organisation. I have a function for each email type (client, org). The form result has been written into a PDF using FPDF. The pdf is attached to both emails. However (this is the odd thing), the pdf is attaching to the org email twice :-S . I have called the clear method in each function, but the issue persists. Here are the mail functions: Code: function _generate_client_email($message_view,$subject,$attachment = '') EDIT - if I call the org function first then I get 2 attachments in the client email. Is there something that I should be clearing further here?
[eluser]joeles[/eluser]
Try $ci->email->clear(true). The parameter tells it to clear attachments as well.
[eluser]ImageSmith[/eluser]
Joeles, I just made the change as per your suggestion, uploaded to test server and submitted the form. OMG! it works :-) You are THE man! Now that's a little item that should be included in the docs. Any idea who we ask to get stuff considered for future inclusion in docs? Thanks again.
[eluser]joeles[/eluser]
Actually, it is in the docs, but don't worry I missed it the first time, too.
[eluser]ImageSmith[/eluser]
By jove, I think you're right. I've read that page at least a dozen times and never spotted that line. (D'Oh!) hut: Cheers again.
[eluser]Chillahan[/eluser]
Wow, hooray for this post! I had the same issue, and I was even MORE confused since I have my e-mailing code in a function that I call within a loop (so it seemed more likely that things should definitely be clear, and that perhaps there was some bug involved in CI). Then I found the clear function but I, too, completely missed that TRUE option! Just seems odd that the send() method wouldn't automatically clear, no? I call this now before sending each time to be safe. |
Welcome Guest, Not a member yet? Register Sign In |