Forums

Admin Email Notification email from subscriber list?

revive 06 Nov, 2008
Hey Max and CC users,

I have setup ChronoComments and all is working great,.. we even added some email parameters for the Admin Template so that we would be able to view the name, email and comment in the notification email... works great and saves time from having to visit them site upon every comment!

My question is, how can I set up ChronoComments to send that Admin Notification email to a subscriber list of 'admins'?? For example, I could create a sign up form where users submit there emails to me and log them in a db table, and then have the Admin Notification template send to all emails in that db table.. is that possible? Well, of course it's possible,.. rather, how do I do that??😀 I am also using ChronoForms, which also ROCKS! so that would be our tool of choice for the form.

Also, of note, I have a couple newsletter programs (Mailing List Manager and SendStudio) that can create sign up forms, track emails and subscribers as well as remain CAN-SPAM compliant if needed. BTW, these will only be some of the suers registered on our Joomla site..

Cheers

J
GreyHead 06 Nov, 2008
Hi revive,

There's a function in the Joomla Registration code that I think is close to what you are looking for here. This uses the Joomla admin mailing settings rather than a separate table but either would work with a little tweaking. In a rush this morning so I'm afraid I've posted the whole function here (from the CF Joomla Registration plugin) and it includes the user emails as well.
function _sendMail(&$user, $password, $emailuser, $emailadmins)
	{
		global $mainframe;

		$db		=& JFactory::getDBO();

		$name 		= $user->get('name');
		$email 		= $user->get('email');
		$username 	= $user->get('username');

		$usersConfig 	= &JComponentHelper::getParams( 'com_users' );
		$sitename 		= $mainframe->getCfg( 'sitename' );
		$useractivation = $usersConfig->get( 'useractivation' );
		$mailfrom 		= $mainframe->getCfg( 'mailfrom' );
		$fromname 		= $mainframe->getCfg( 'fromname' );
		$siteURL		= JURI::base();

		$subject 	= sprintf ( JText::_( 'Account details for' ), $name, $sitename);
		$subject 	= html_entity_decode($subject, ENT_QUOTES);

		if ( $useractivation == 1 ){
			$message = sprintf ( JText::_( 'SEND_MSG_ACTIVATE' ), $name, $sitename, $siteURL."index.php?option=com_user&task=activate&activation=".$user->get('activation'), $siteURL, $username, $password);
		} else {
			$message = sprintf ( JText::_( 'SEND_MSG' ), $name, $sitename, $siteURL);
		}

		$message = html_entity_decode($message, ENT_QUOTES);

		//get all super administrator
		$query = 'SELECT name, email, sendEmail' .
				' FROM #__users' .
				' WHERE LOWER( usertype ) = "super administrator"';
		$db->setQuery( $query );
		$rows = $db->loadObjectList();

		// Send email to user
		if ( ! $mailfrom  || ! $fromname ) {
			$fromname = $rows[0]->name;
			$mailfrom = $rows[0]->email;
		}
		if($emailuser == "Yes")
		JUtility::sendMail($mailfrom, $fromname, $email, $subject, $message);

		// Send notification to all administrators
		$subject2 = sprintf ( JText::_( 'Account details for' ), $name, $sitename);
		$subject2 = html_entity_decode($subject2, ENT_QUOTES);

		// get superadministrators id
		foreach ( $rows as $row )
		{
			if (($row->sendEmail)&&($emailadmins == "Yes"))
			{
				$message2 = sprintf ( JText::_( 'SEND_MSG_ADMIN' ), $row->name, $sitename, $name, $email, $username);
				$message2 = html_entity_decode($message2, ENT_QUOTES);
				JUtility::sendMail($mailfrom, $fromname, $row->email, $subject2, $message2);
			}
		}
	}

Bob
revive 06 Nov, 2008
Hey Bob,

Thanks for the code snippet.. could you direct me in the best implementation of this with ChronoComments?
Thanks again!
J
Max_admin 06 Nov, 2008
Hi Jessy,

the same way you did the hack at the other thread, you can make a simple SQL query to load your list of subscribers and loop through them and send the email each time.

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
revive 06 Nov, 2008
Hey Max,

Yes, I know that I can query the SQL for joomla users, but I would like to have ChronoForms store to a new table, that is just for these users that need updates... I haven't linked ChronoForms with SQL yet and made it so someone can subscribe/unsubscribe.. to me, it seems like a form with dual functions.. to store someone in a database and also the ability to remove them if they enter the correct username/email that has been stored in the table..

Can you shoot me some direction on how to make this happen??😀


Thanks

Jesse
Max_admin 06 Nov, 2008
Hi Jesse, you need to make the Chronoform to store the users or you need the hack to let ChronoComments email the list of users created by this form ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
revive 06 Nov, 2008
Hey Max,

I need the hack that would allow ChronoComments to send this email to the emails in the table that the ChronoForms is storing to.. preferably the ability to include both Name and Email. I'll be using a basic form: Name, Email, CAPTCHA, Subscribe and Unsubscribe.
Max_admin 06 Nov, 2008
Good, about the hack, as I mentioned earlier, you just need to do it the way you did that other hack, the only difference is the loop after you get all subscribers list!

regarding the form itself, if you have questions then try to make a Chronoforms forum post!

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
revive 06 Nov, 2008
Yeah.. and I'm lost LOL.. the other hack was simply adding additional 'name' and 'email' variables that the admin template called to that I could use that in the email template.. I basically used the code that was present, copied and changed the names.. pretty newb I know, but it worked.
Would you be willing to help me with this implementation?
Thanks Max,

Jesse
Max_admin 07 Nov, 2008
Lets talk about the email thing, do you know how to make a SQL query to load the emails list and loop through them with foreach statement and at every loop you do the email function line of code ?

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
revive 07 Nov, 2008
Hey Max,

No, i have no clue how to make a SQL query to do that, nor how to script the loop feature.😟
Pretty well versed in CSS/HTML, just learning PHP... but really more of a graphics/front end guy...
J
Max_admin 07 Nov, 2008
No problems, here is the idea :


$query = "SELECT * FROM #__chronoforms_table";
$database->setQuery( $query );
$rows = $database->loadObjectList();
foreach($rows as $row){
JUtility::sendMail($configs->get('nemail_fromemail'), $configs->get('nemail_fromname'), $row->subscriber_email, $subject, $email_body, true, NULL, NULL, NULL, NULL, NULL );
}
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
revive 07 Nov, 2008
Max,
Did I mention that you rock!?!?! Thanks man, I really appreciate the help on this! I will get back to you and let you know how its going..

Cheers
J
revive 08 Nov, 2008
Ok, still seems to be above my 'pay grade' lol.. My brain is fried and it's no where close to working.. so, I'll pause the thread here, and will post a request for quote on the Professional Paid Services board.
J
Max_admin 08 Nov, 2008
Hi Jesse, at the code above you will change the table name and fill the email parameters and you are done!

Cheers
MAx
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.