How to email users of a particular group?

Good day!

Familiar with modx. I want to make a simple sending letters to people who are in a certain group or who have a role to play. I want to implement using the modx api. Found how to get user id, but how to loop through the users groups and get their email or does not work...
June 10th 19 at 15:17
1 answer
June 10th 19 at 15:19
Solution
Did the following:
$query = $this->modx->newQuery('modUser');
$users = $this->modx->getCollection('modUser', $query);
foreach($users as $i => $user) {
 $id = $user->id;
 if ( $user->isMember('Administrator') ) {
 $profile = $user->getOne('Profile');
 $email = $profile->get('email');
 if ( !is_null($email) ) {
 $mail->address('to', $email);
}
}
}

Find more questions by tags MODX