Hello all,
I'm new to Joomla! and ChronoForms, I'm using a piece of PHP written by Bettie111111 that allows me to hide email recipients in a dropdown menu, here it is:
What I'm attempting to do is send to multiple addresses from each dropdown option, I've looked at some PHP resources with no luck. Is there an easy solution for this or do I need to convince the Exchange guy to create some new groups for me?
Thank you!
Cheers<
Kevin
I'm new to Joomla! and ChronoForms, I'm using a piece of PHP written by Bettie111111 that allows me to hide email recipients in a dropdown menu, here it is:
} elseif ($_POST['select_0'] == "Spiritual Formation/Christian Education") {
$_POST['hidden_0'] = "xxx@gallowayumc.org";
} elseif ($_POST['select_0'] == "Spiritual Formation/Christian Education") {
$_POST['hidden_0'] = "yyy@gallowayumc.org";
What I'm attempting to do is send to multiple addresses from each dropdown option, I've looked at some PHP resources with no luck. Is there an easy solution for this or do I need to convince the Exchange guy to create some new groups for me?
Thank you!
Cheers<
Kevin
Hi Kevin,
This is partly covered in the FAQ#31, you might also find this thread useful. Just change the single recipient into a comma-separated list of emails.
/Fredrik
This is partly covered in the FAQ#31, you might also find this thread useful. Just change the single recipient into a comma-separated list of emails.
/Fredrik
Fredrik,
I have attempted the follow code and still get PHPMailer errors:
with those code it sends to address xxx and not yyy:
Thoughts? I'm miserable at hand coding anything, so all help is thoroughly appreciated.
Cheers,
Kevin
I have attempted the follow code and still get PHPMailer errors:
$_POST['hidden_0'] = "xxx@gallowayumc.org", "yyy@gallowayumc.org";
}
$_POST['hidden_0'] = "xxx@gallowayumc.org, yyy@gallowayumc.org";
}
with those code it sends to address xxx and not yyy:
$_POST['hidden_0'] = "jslack@gallowayumc.org"; "kslark@gallowayumc.org";
}
Thoughts? I'm miserable at hand coding anything, so all help is thoroughly appreciated.
Cheers,
Kevin
Hi Kevin,
I believe you misunderstood me regarding a comma-separated list of emails...
What you've put there, is a semi-colon after the whole string, acting as a command terminator. Thus, whatever follows that semi-colon will be considered a new command. What you need instead, is something like this:
/Fredrik
I believe you misunderstood me regarding a comma-separated list of emails...
What you've put there, is a semi-colon after the whole string, acting as a command terminator. Thus, whatever follows that semi-colon will be considered a new command. What you need instead, is something like this:
...
$_POST['hidden_0'] = "jslack@gallowayumc.org, kslark@gallowayumc.org";
...
/Fredrik
Fredrik,
I did in fact misunderstand you, thank you for all your help.
My code now looks like this:
and I get the following error when I submit the form:
* [email]PHPMAILER_RECIPIENTS_FAILEDjslack@gallowayumc.org[/email], [email]kslark@gallowayumc.org[/email]
The form can be found here http://ecbiz60.inmotionhosting.com/~gallow5/index.php?option=com_chronocontact&chronoformname=comments, I'm currently testing with the "Web Site Comments" section as I don't want to bother the rest of my colleagues with this issue.
Thank you again!
Peace,
Kevin
I did in fact misunderstand you, thank you for all your help.
My code now looks like this:
} elseif ($_POST['select_0'] == "Web Site Comments") {
$_POST['hidden_0'] = "jslack@gallowayumc.org, kslark@gallowayumc.org";
and I get the following error when I submit the form:
* [email]PHPMAILER_RECIPIENTS_FAILEDjslack@gallowayumc.org[/email], [email]kslark@gallowayumc.org[/email]
The form can be found here http://ecbiz60.inmotionhosting.com/~gallow5/index.php?option=com_chronocontact&chronoformname=comments, I'm currently testing with the "Web Site Comments" section as I don't want to bother the rest of my colleagues with this issue.
Thank you again!
Peace,
Kevin
G'day Kevin,
I just checked the source, and the comma separation will only work for static to, not dynamic to. The solution is to use the FAQ#31 approach and static to:
Also remember to remove the dynamic to input from your email setup.
/Fredrik
I just checked the source, and the comma separation will only work for static to, not dynamic to. The solution is to use the FAQ#31 approach and static to:
<?
/* Set up some objects to manage the email */
$cf =& CFChronoForm::getInstance('comments');
$emails =& CFEmails::getInstance($cf->formrow->id);
switch (JRequest::getString('select_0')) {
case 'Web Site Comments':
$emails->setEmailData(1, 'to', 'jslack@gallowayumc.org, kslark@gallowayumc.org');
break;
case 'Something else...'
$emails->setEmailData(1, 'to', 'blahbla');
break;
default:
$emails->setEmailData(1, 'to', 'default@gallowayumc.org');
}
?>
Also remember to remove the dynamic to input from your email setup.
/Fredrik
Hi Kevin,
That's a PHP Mailer error message. Please check first with a single email address and it should work OK. For two email addresses, either the space between them is a problem; or they need to be in an array rather than a list.
Bob
That's a PHP Mailer error message. Please check first with a single email address and it should work OK. For two email addresses, either the space between them is a problem; or they need to be in an array rather than a list.
Bob
G'day Bob,
I believe arrays will not work, as the type of the submitted data is expected to be a string. Further, the content of the $recipients array is expected to be strings; implode() cannot handle multi-level arrays well, and JMail->addRecipient() expects either a string or an array of strings (if anything would get through the first step, you'd have an array of arrays of strings).
Spaces should be handled correctly by the PHPMailer class, but I have not verified this.
/Fredrik
I believe arrays will not work, as the type of the submitted data is expected to be a string. Further, the content of the $recipients array is expected to be strings; implode() cannot handle multi-level arrays well, and JMail->addRecipient() expects either a string or an array of strings (if anything would get through the first step, you'd have an array of arrays of strings).
Spaces should be handled correctly by the PHPMailer class, but I have not verified this.
/Fredrik
This topic is locked and no more replies can be posted.