Forums

Send an email to Joomla users group (To Admin, To Registers, or To third...)

cyborg_b 31 Jan, 2014
Hello,
I'm trying to send email To particular group of Joomla users. I guess, I need a php code, wich will collect users from a one group ID, separate by the commas, and to put into a "Send To" field. There is a only small problem, I don't know php😟

I have found one solution on the page http://www.chronoengine.com/forums/posts/f8/t16628.html?page=1 , but this is for the ChronoForms V3.

Please, help if you know something about this problem.
GreyHead 08 Feb, 2014
Hi cyborg_b,

I'm sorry, I know Joomla! has some code that will let you look up the members of a group but I don't remember exactly what it is. Google may help.

Bob
cyborg_b 11 Feb, 2014
Thank you GreyHead,

I've searched over the Google. Read Joomla 3 documentation, and I have found way how to write query which select emails of a users from particular users group. Tested query into phpMyadmin, and then I've put them into a list.

<?php
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query
    ->select($db->quoteName(array('a.email')))
    ->from($db->quoteName('#__users', 'a'))
    ->join('LEFT', $db->quoteName('#__user_usergroup_map', 'b') . ' ON (' . $db->quoteName('a.id') . ' = ' . $db->quoteName('b.user_id') . ')')
    ->where($db->quoteName('b.group_id') . '=8');
// Number 8 represent ID of a "group_id" from "_user_usergroup_map" table
$db->setQuery($query);
// load results from query
$emails= $db->loadColumn();
// order result separated by comas
$list = implode(",", $emails);
print_r($list);
//echo $query;
?>


Now I need help to find way how to put this CSV list into, I guest, "Dynamic to" email field of ChronoForms.
Note. I'm using ChronoForm 5 on Joomla 3.2 site.
GreyHead 11 Feb, 2014
Hi cyborg_b,

I have no idea if Max's CFv5 Email action will support a list (or an array) but here's how I'd test. Replace this line
$list = implode(",", $emails);
with
$form->data['list'] = implode(",", $emails);
Then put list (without quotes or brackets) in the Dynamic To box of the email action.

Bob
cyborg_b 11 Feb, 2014
Yes, you gave me a proper code for list of comma separated emails. Thanx!
I've entered code, tested and debuged. Everything looks good (see PrintScr. http://screencast.com/t/jrIgsU5o), except one thing.
I didn't get emails😟
Yes, I've checked my spam folder....

note: email for the PrintSCr. are changed for safety reasons.
GreyHead 12 Feb, 2014
Hi cyborg_b,

Two things to test please:

+ Change the From Email address to one that matches the domain of your site.

+ if you use just a single email rather that a list is the email then sent?

Bob

Bob
cyborg_b 12 Feb, 2014
No, not sending yet 😟
I have put regular email address with domain prefix....
When I put email in "To" field, only this email gets email. Even, it is listed in a group with other emails, taken by the query.

Note, the same thing is happening on both ChronoForms v4 and v5.

(See printScr. http://screencast.com/t/hzetwiOIwgSu )
GreyHead 12 Feb, 2014
Hi cyborg_b,

Sorry, I don't know CFv5 well enough to know if adding a dynamic array or list of addresses is supported or not. I do know that in CFv4 you can do it with my custom Email [GH] action.

Bob
cyborg_b 12 Feb, 2014
Big thanx to you Greyhead for all support that you provide me,
I will try your "CFv4 Email [GH] action" a.s.a.p., and than will add review to the forum.
In the meaning time, I suppose, that someone will know the key for my problem!

Regards,
cyborg_b😀
This topic is locked and no more replies can be posted.