Hi Bob,
I wonder if we can simplify the code below because if I send for many variables (em2, 3,4,5,6,7,8,9) at the same address. And most importantly, I want to know how to create conditions among its variables. Example: if there is (EM4 + EM10) or (+ EM6 EM10) then send exemple@exemple.com.
Again thank you.
Eric
I wonder if we can simplify the code below because if I send for many variables (em2, 3,4,5,6,7,8,9) at the same address. And most importantly, I want to know how to create conditions among its variables. Example: if there is (EM4 + EM10) or (+ EM6 EM10) then send exemple@exemple.com.
Again thank you.
Eric
<?php
$recipient = JRequest::getString('recipients', '', 'post');
$emails = array (
'em1' => 'exempleA@hotmail.com',
'em2' => 'exempleB@orange.fr',
'em3' => 'exempleB@orange.fr',
'em4' => 'exempleC@orange.fr',
'em5' => 'exempleC@orange.fr',
'em6' => 'exempleB@orange.fr',
);
$email_to_use = $emails[$recipient];
$form->data['email_to_use'] = $email_to_use;
$recipient2 = JRequest::getString('recipients2', '', 'post');
$emails2 = array (
'em7' => 'exempleB@orange.fr',
'em8' => 'exempleC@orange.fr',
'em9' => 'exempleB@orange.fr',
'em10' => 'esempleA@hotmail.com',
);
$email_to_use2 = $emails2[$recipient2];
$form->data['email_to_use2'] = $email_to_use2;
?>
Hi Eric,
Your specification is very vague so it's hard to give you a specific reply.What exactly is the logic that you want to use?
Here's my attempt at an answer - but it may not answer your question :-(
The first thing to notice is that the standard Email action in CFv4 will not let you send to more than one dynamic To Email address. If you need to do that you will want to get my Email [GH] action which will accept an array of email addresses.
Then your code will be like this:
Bob
Your specification is very vague so it's hard to give you a specific reply.What exactly is the logic that you want to use?
Here's my attempt at an answer - but it may not answer your question :-(
The first thing to notice is that the standard Email action in CFv4 will not let you send to more than one dynamic To Email address. If you need to do that you will want to get my Email [GH] action which will accept an array of email addresses.
Then your code will be like this:
<?php
$emails_array = array();
$emails = array (
'em1' => 'exempleA@hotmail.com',
'em2' => 'exempleB@orange.fr',
'em3' => 'exempleB@orange.fr',
'em4' => 'exempleC@orange.fr',
'em5' => 'exempleC@orange.fr',
'em6' => 'exempleB@orange.fr',
);
$recipients = $form->data['recipients'];
if ( is_array($recipients) ) {
foreach ( $recipients as $r ) {
$emails_array[] = $emails[$r];
}
} else {
$emails_array[] = $emails[$recipients];
}
$emails2 = array (
'em7' => 'exempleB@orange.fr',
'em8' => 'exempleC@orange.fr',
'em9' => 'exempleB@orange.fr',
'em10' => 'exempleA@hotmail.com',
);
$recipients2 = $form->data['recipients2'];
if ( is_array($recipients2) ) {
foreach ( $recipients2 as $r ) {
$emails_array[] = $emails[$r];
}
} else {
$emails_array[] = $emails[$recipients2];
}
if ( ( $recipient == 'em4' || in_array('em4', $recipent) ) && ( $recipent2 == 'em10' || in_array('em10', $recipent2) ) ) {
$emails_array[] = 'some_email@example.com';
}
if ( ( $recipient == 'em6' || in_array('em6', $recipent) ) && ( $recipent2 == 'em10' || in_array('em10', $recipent2) ) ) {
$emails_array[] = 'some_email_b@example.com';
}
// remove any duplicate entries
$emails_array = array_unique($emails_array);
//
make sure that there is at least one email
if ( count($emails_array) <= 0 ) {
$emails_array[] = 'default_email@example.com';
}
$form->data['email_to_use'] = $emails_array;
?>
Bob
I'll try to clarify my question.
I have two dropdown:
The first (containers) offers skill levels:
em1 = Official Commissioner Track
em2 = Official Steward
em3 = Official Race Director
EM4 = Official Scrutineer
EM5 = Official Commissioner Zone
EM6 = Official Timekeeper
The second (recipients2) Disciplines:
em7 = Enduro
EM8 = Motocross
EM9 = Trial
EM10 = Speed
Depending on the choices made, an email must be sent to different addresses:
When "Speed" is selected the mail must always be sent to: exempleA@exemple.com. Except when "Official Timekeeper" or "Scrutineer" are selected, then the mail is to be sent to exempleB@exemple.com. For all other choices the mail must be sent to exempleC@exemple.com.
I have undestand that I must use your Email [GH] action, and i do that.
I'm working on the code that you suggested me to get the desired result, but for now I get: No valid To Email address found in the report of "debug data".
Thanks
Erick
I have two dropdown:
The first (containers) offers skill levels:
em1 = Official Commissioner Track
em2 = Official Steward
em3 = Official Race Director
EM4 = Official Scrutineer
EM5 = Official Commissioner Zone
EM6 = Official Timekeeper
The second (recipients2) Disciplines:
em7 = Enduro
EM8 = Motocross
EM9 = Trial
EM10 = Speed
Depending on the choices made, an email must be sent to different addresses:
When "Speed" is selected the mail must always be sent to: exempleA@exemple.com. Except when "Official Timekeeper" or "Scrutineer" are selected, then the mail is to be sent to exempleB@exemple.com. For all other choices the mail must be sent to exempleC@exemple.com.
I have undestand that I must use your Email [GH] action, and i do that.
I'm working on the code that you suggested me to get the desired result, but for now I get: No valid To Email address found in the report of "debug data".
Thanks
Erick
Hi Bob,
My debug data are :
Data Array:
Array
(
[option] => com_chronoforms
[tmpl] => component
[chronoform] => Multimails
[event] => submit
[Itemid] =>
[input_text_1] =>
[input_text_2] =>
[recipients] => em4
[recipients2] => em10
[input_submit_4] => Envoyer
[32c763b6cb29c5fd4e2733940e324e4a] => 1
[IPADDRESS] => 82.XX.XX;XX
)
Validation Errors:
Array
(
)
Merci pour votre inscription
Debug Data
Email errors
No valid To Email address found
Email info
Email send stopped.
From: (admin) info@www.exemple.org
To:
Subject: multimails
Email body
Nom
email
service em4
Eric
My debug data are :
Data Array:
Array
(
[option] => com_chronoforms
[tmpl] => component
[chronoform] => Multimails
[event] => submit
[Itemid] =>
[input_text_1] =>
[input_text_2] =>
[recipients] => em4
[recipients2] => em10
[input_submit_4] => Envoyer
[32c763b6cb29c5fd4e2733940e324e4a] => 1
[IPADDRESS] => 82.XX.XX;XX
)
Validation Errors:
Array
(
)
Merci pour votre inscription
Debug Data
Email errors
No valid To Email address found
Email info
Email send stopped.
From: (admin) info@www.exemple.org
To:
Subject: multimails
Email body
Nom
service em4
Eric
Hi Eric,
As you see 'email_to-use' isn't there at all so you need to debug your code and work out what is happening.
Bob
As you see 'email_to-use' isn't there at all so you need to debug your code and work out what is happening.
Bob
Hi bob,
I don't know why, but when i erased the conditions :
if ( ( $recipient == 'em4' || in_array('em4', $recipent) ) && ( $recipent2 == 'em10' || in_array('em10', $recipent2) ) { $emails_array[] = 'exemple@hotmail.com'; }
if ( ( $recipient == 'em6' || in_array('em6', $recipent) ) && ( $recipent2 == 'em10' || in_array('em10', $recipent2) ) { $emails_array[] = 'exemple@orange.fr'; }
I have :
[email_to_use] =>
and :
Email sent successfully
Perhaps one part of code is not valide for joomla 2.5?
I don't know why, but when i erased the conditions :
if ( ( $recipient == 'em4' || in_array('em4', $recipent) ) && ( $recipent2 == 'em10' || in_array('em10', $recipent2) ) { $emails_array[] = 'exemple@hotmail.com'; }
if ( ( $recipient == 'em6' || in_array('em6', $recipent) ) && ( $recipent2 == 'em10' || in_array('em10', $recipent2) ) { $emails_array[] = 'exemple@orange.fr'; }
I have :
[email_to_use] =>
and :
Email sent successfully
Perhaps one part of code is not valide for joomla 2.5?
Hi Bob,
I have find ! The probleme is : two ")" missing for closed de code at the end of the "if" betwen $recipent2) ) ")" { $email...
Thank you again Bob.
Eric
I have find ! The probleme is : two ")" missing for closed de code at the end of the "if" betwen $recipent2) ) ")" { $email...
Thank you again Bob.
Eric
This topic is locked and no more replies can be posted.