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...
$mh = Loader::helper('mail');
$mh->from([email protected]');
$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.

Sadu
View Replies:
Sadu replied on at Permalink Reply
Sadu
OK, so after an hour trying to figure this out, I post a message on the forum, then 2 mins later I find the solution.

Just replace the first line of code ion my example with the following...
Loader::helper('mail');
$mh = new MailHelper();
brianvandelden replied on at Permalink Reply
brianvandelden
Thanks! Just the answer i was looking for