Mail helper - multiple instances
Permalink
Hi Everyone,
I'm wanting to use the mail helper to send different emails to multiple addresses. However, I can't seem to figure out how to clear the 'to' array from the mail helper. Every time I use the helper it appends the new address to the existing "to" array.
Can someone advise how to clear out the mail helper, or how to use a fresh instance?
This was mentioned in the following thread, but without any particular solution offered...
http://www.concrete5.org/community/forums/usage/mail-helper-andgtto...
Here's the code I'm using...
This code is inside a function which is called multiple times. I have tried unsetting $mh, and have tried assigning Loader::helper('mail') to a new variable. Neither of these seem to work.
I'm wanting to use the mail helper to send different emails to multiple addresses. However, I can't seem to figure out how to clear the 'to' array from the mail helper. Every time I use the helper it appends the new address to the existing "to" array.
Can someone advise how to clear out the mail helper, or how to use a fresh instance?
This was mentioned in the following thread, but without any particular solution offered...
http://www.concrete5.org/community/forums/usage/mail-helper-andgtto...
Here's the code I'm using...
$mh = Loader::helper('mail'); $mh->from('test@example.com'); $mh->to($to_email); $mh->load('my_template'); $mh->sendMail();
This code is inside a function which is called multiple times. I have tried unsetting $mh, and have tried assigning Loader::helper('mail') to a new variable. Neither of these seem to work.
Just replace the first line of code ion my example with the following...