I have an extension that sends out emails to certain members (based on member group and custom profile fields). For some members, this includes a file attachment. All of the members receiving attachments receive the same exact attachment.
The problem I’m having is that the emails are getting a duplicate attachment and it increases +1 for each email. So, if there are 20 members eligible to receive the attachment, the 20th email sent will have the attachment 20 times.
I’m using straight-foward EEmail class code for this, just like is specified in the docs under Sending Multiple Email.
So, can attachments not be used when sending emails in a loop?
(As an aside, I’ve noticed that initialize() function does not clean up attachments.)
Any thoughts/help/advice would be great. Thanks!
Well, in 1.x, where attach() is undocumented and incomplete, yes. In CI/2.0 you’ll notice that clear() resets file attachments unless it’s told not to specifically. In either case, if your goal is for every person to get the same attachment, then setting it once outside of the loop is the way you’d want to go to minimize overhead from redundant method calls.
Well, in 1.x, where attach() is undocumented and incomplete, yes. In CI/2.0 you’ll notice that clear() resets file attachments unless it’s told not to specifically. In either case, if your goal is for every person to get the same attachment, then setting it once outside of the loop is the way you’d want to go to minimize overhead from redundant method calls.
Yeah, I acknowledge I’m using an incomplete and undocumented feature. 😊 Of course the obvious fix you pointed out wasn’t so obvious to me. Gah! I’m all set now by taking it out of the loop.
Thanks for the assistance and for the details on 2.0, Derek.
Your nemesis,
Ryan
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.