Buy Now
Sign in

Group email with chronoforms

danr , December 20 2009
D
danr
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
D
danr
Can anyone help with this ??
admin
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
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
D
danr
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
D
danr
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
admin
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
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
D
danr
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
admin
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
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
D
danr
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
U
uzoom
Great and simple solution for this problem thank you.

Jen
C
cyborg_b
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
admin
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
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!