Forums

Group email with chronoforms

danr 20 Dec, 2009
Hi
I would like some help in realising the following;
1. A user submits an enquiry form on the site. This will have about 15 fields ( name, email, two date pickers and chechboxes, captcha etc).
2. After the user submits the form I would like all the data from the submitted form to be sent to all the users that have "author" status on the website. It is likely that the number of authors will increase over time and must also accomodate this. The data after submission is no longer required. The site currently uses SMTP for mail sending.

I have started a thread with this issue http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=2&t=16591

If anyone is interested please email me or reply to post. My site is http://www.rentfloridavillas.net. Please include any costs involved.
Thanks in advance.
Danny
danr 14 Apr, 2010
Can anyone help with this ??
Max_admin 16 Apr, 2010
Hi danr,

You better load those users emails through a db query then use the built in Chronoforms function which sets the email settings, set the "To" to the emails list appended by commas

in your form's before email box

<?php
$emails = array of emails you get through your query
$list = implode(",", $emails);
$MyForm =& CFChronoForm::getInstance('form_name'here');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyFormEmails->setEmailData(1, 'To', $list);
?>



Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
danr 01 May, 2010
Hi Max
Thanks for the reply. I am still struggling a bit with the call for id's with the database. I am using this code
$query = 'SELECT email'
	. ' FROM #__users'
	. ' WHERE id = author'.(int) $user->get('id')
	;
	$db->setQuery( $query );
	$user->set( 'email', $db->loadResult() );

<?php
$emails = array of emails you get through your query
$list = implode(",", $emails);
$MyForm =& CFChronoForm::getInstance('form_name'basicDemo');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyFormEmails->setEmailData(1, 'email', $list);
?>

	

I have placed this also into the 'on submit before email sending' before the code that you have supplied.

however i'm getting the following error which I cant seem to solve. Have you come accross this before ?
Parse error: syntax error, unexpected T_STRING, expecting '(' in /home/rentflor/public_html/components/com_chronocontact/libraries/customcode.php(64) : eval()'d code on line 11

Any help is greatly appreciated.

Regards
Danr
danr 03 May, 2010
Have now altered code as follows, still no joy though !!

$db =& JFactory::getDBO();
$query = "SELECT * FROM #__users WHERE gid>19";
$db->setQuery($query);
$rows = $db->loadObjectList();
$user->set( 'email', $db->loadResult() );

<?php
$emails = array of emails you get through your query
$list = implode(",", $emails);
$MyForm =& CFChronoForm::getInstance('form_name'basicDemo');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyFormEmails->setEmailData(1, 'email', $list);
?>


Any help paid or unpaid welcome. Thanks in advamce.
Danr
Max_admin 04 May, 2010
try to change the code to:

<?php
$db =& JFactory::getDBO();
$query = "SELECT email FROM #__users WHERE gid>19";
$db->setQuery($query);
$emails = $db->loadResult();

$list = implode(",", $emails);
$MyForm =& CFChronoForm::getInstance('basicDemo');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyFormEmails->setEmailData(1, 'To', $list);
?>
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
danr 06 May, 2010
Thanks for the quick response. I have been trying to still get this form to work. I have this in the on submit form
<?php
$db =& JFactory::getDBO();
$query = "SELECT email FROM #__users WHERE gid>18";
$db->setQuery($query);
$emails = $db->loadResultArray();

$list = implode(",", $emails);
$MyForm =& CFChronoForm::getInstance('contact');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyFormEmails->setEmailData(1, 'To', $list);
print_r($MyFormEmails);
?>


and I have added the word 'list' without commas into the 'dynamic to' field in the email setup.

Unfortunately i am getting this error

You must provide at least one recipient e-mail address.



and the extra emails shown above are not being sent an email. I am not really sure what to do now. Any help would be greatly appreciated.

Thanks for your help

regards
Danr
Max_admin 07 May, 2010
Hi Danr,

remove anything in the dynamic To field in your email

and change this line :
$MyFormEmails->setEmailData(1, 'To', $list);


to
$MyFormEmails->setEmailData(1, 'to', $list);


let me know

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
danr 14 May, 2010
Hi
It works. doing like you mentioned changing the 'To' to 'to' enabled the emails to be sent.
Although this did not work for me as it gave out all the email address of all the other 'author' status members. I have changed the 'to' to 'bcc'.

Thanks again for your help.

Regards
Danr
uzoom 02 Jun, 2010
Great and simple solution for this problem thank you.

Jen
cyborg_b 29 Jan, 2014
Hello,
I'm trying to include this code into ChF v4 and ChF v5 but i'm stuck somewhere😟
I have a print screen http://screencast.com/t/FmbU3Sm23C and a few questions:
1. Do I'm working corectly?
2. Does upper code work in all versions of Chronoforms?
3. What represens number 18 in the above code?

Any help would be helpful!

Regards,
Bob
Max_admin 30 Jan, 2014
Hi cyborg_b,

Please start a new topic with more info about your problem and we will try to help!

And no, the code above was for v3, so it will not work neither in v4 nor in v5 at all!

Regards,
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.