<?php
$group = $modx->getObject('modUserGroup',array('name' => testing));
$members = $group->getMany('UserGroupMembers');
$message = $modx->getChunk('email-manuscripts');
$modx->getService('mail', 'mail.modPHPMailer');
$modx->mail->set(modMail::MAIL_BODY,$message);
$modx->mail->set(modMail::MAIL_FROM,'[email protected]');
$modx->mail->set(modMail::MAIL_FROM_NAME,'SSPM Manuscripts');
$modx->mail->set(modMail::MAIL_SUBJECT,'Email test');
foreach ($members as $member){
$user = $modx->getObject('modUser',$member->get('member'));
$modx->mail->address('to',$user->get('username'));
}
$modx->mail->address('reply-to','[email protected]');
$modx->mail->setHTML(true);
if (!$modx->mail->send()) {
echo 'mail send failed';
}else{
echo 'mail sent';
}
$modx->mail->reset();This question has been answered by claytonk. See the first response.
$group = $modx->getObject('modUserGroup',array('name' => testing));$group = $modx->getObject('modUserGroup',array('name' => 'testing'));
foreach ($members as $member){
$user = $modx->getObject('modUser',$member->get('member'));
$modx->mail->address('to',$user->get('username'));
}
foreach ($members as $member){
$profile = $modx->getObject('modUserProfile', array('internalKey' => $member->get('member'));
$modx->mail->address('to',$profile->get('email'));
}
I took a look at Notify, but it looked like the only way to execute the send was via a resource preview.
Quote from: claytonk at May 17, 2015, 06:39 PMI took a look at Notify, but it looked like the only way to execute the send was via a resource preview.
No, Notify launches from the Create/Edit Resource panel. There's a button on the TV tab that says "Launch Notify. I use it all the time to send out a quick messages to members of a user group, and you can create several different Tpls to choose from for the message (or use a blank one).
$group = $modx->getObject('modUserGroup',array('name' => testing));
should be
$group = $modx->getObject('modUserGroup',array('name' => 'testing'));
You also don't seem to be passing any actual email addresses? Just the username?In this case the username is the email address.