Referring to the tutorial on http://www.chronoengine.com/faqs/52-cfv4/cfv4-emails/2603-how-can-i-send-an-email-to-different-addresses.html , I have few questions to ask:
1. It is stated that the email action is enabled and has standard Static values for Subject, From Name and From Email. What if I also want to have dynamic subject for the email. I found the tutorial for dynamic subject, http://www.chronoengine.com/faqs/52-cfv4/cfv4-emails/2569-how-do-i-create-an-email-subject-using-data-from-the-form.html , and tried to combine both codes in a single custom code field. But it doesn't work.
2. Following the example illustrated in the tutorial, what if the mail sent to different departments also contains the department name in the email body?
If the email recipient is bob@example.com, so the email body will be:
Dear Bob,
Lorem ipsum dolor sir amet......
If the email recipient is info@example.net, so the email body will be:
Dear Info Department,
Lorem ipsum dolor sir amet......
Thank you.
1. It is stated that the email action is enabled and has standard Static values for Subject, From Name and From Email. What if I also want to have dynamic subject for the email. I found the tutorial for dynamic subject, http://www.chronoengine.com/faqs/52-cfv4/cfv4-emails/2569-how-do-i-create-an-email-subject-using-data-from-the-form.html , and tried to combine both codes in a single custom code field. But it doesn't work.
2. Following the example illustrated in the tutorial, what if the mail sent to different departments also contains the department name in the email body?
If the email recipient is bob@example.com, so the email body will be:
Dear Bob,
Lorem ipsum dolor sir amet......
If the email recipient is info@example.net, so the email body will be:
Dear Info Department,
Lorem ipsum dolor sir amet......
Thank you.
Hi adhynagara2,
1. Please post the code that you have used. You can combine both in the same Custom Code action provided that you are writing valid PHP.
2. If you add the Department name to the $form->data array as - for example $form->data['department_name'] = 'Some Department'; then you can use {department_name} in the Email template.
The code to set this would be similar to the Email code.
Bob
1. Please post the code that you have used. You can combine both in the same Custom Code action provided that you are writing valid PHP.
2. If you add the Department name to the $form->data array as - for example $form->data['department_name'] = 'Some Department'; then you can use {department_name} in the Email template.
The code to set this would be similar to the Email code.
Bob
Hi Mr. GreyHead,
Here is my code
I tried to submit a form which contains Jakarta as the city, but the email was delivered to makassar@domain.com, instead of jakarta@domain.com). Meanwhile the subject of the delivered email was correct as expected (means that nothing's wrong with the code for dynamic subject).
Regarding the question #2, I am amazed that the trick is way more simple than I expected. Thank you.
Here is my code
<?php
$form->data['subject'] = "{$form->data['Time']} with {$form->data['Title']} {$form->data['Name']}";
?>
<?php
// set a default recipient
$recipient = 'makassar';
if ( isset($form->data['city']) && $form->data['city'] ) {
$recipient = $form->data['city'];
}
$emails = array (
'makassar' => 'makassar@domain.com',
'jakarta' => 'jakarta@domain.com',
'bandung' => 'bandung@domain.com' );
$form->data['email_to_use'] = $emails[$recipient];
?>
I tried to submit a form which contains Jakarta as the city, but the email was delivered to makassar@domain.com, instead of jakarta@domain.com). Meanwhile the subject of the delivered email was correct as expected (means that nothing's wrong with the code for dynamic subject).
Regarding the question #2, I am amazed that the trick is way more simple than I expected. Thank you.
Hi adhynagara2,
Just to check does your form Submit Jakarta or jakarta? PHP thinks that those are two different values.
Bob
Just to check does your form Submit Jakarta or jakarta? PHP thinks that those are two different values.
Bob
Awesome. It now works like a charm.
You are super genious, Mr. GreyHead!
Happy Easter...
You are super genious, Mr. GreyHead!
Happy Easter...
Hello,
I have a similar problem with sending emails to different recipients.
I followed the tutorial step by step by applying it to a form with a group of checkboxes, but I end up with debugging errors.
In particular, what I would do is this: according to the selected checkbox to send the email to multiple recipients.
The code I used is this:
but emails are not sent. seems you select a single recipient (but does not receive the email too).
I enclose a screenshot.
I have a similar problem with sending emails to different recipients.
I followed the tutorial step by step by applying it to a form with a group of checkboxes, but I end up with debugging errors.
In particular, what I would do is this: according to the selected checkbox to send the email to multiple recipients.
The code I used is this:
<?php
// set a default recipient
$recipient = 'mail1';
if ( isset($form->data['recipients']) && $form->data['recipients'] ) {
$recipient = $form->data['recipients'];
}
$emails = array (
'mail1' => 'mail1@gmail.com',
'mail2' => 'mail2@outlook.it',
'mail3' => 'netwxxxxxx@xxxi.it' );
$form->data['email_to_use'] = $emails[$recipient];
?>
but emails are not sent. seems you select a single recipient (but does not receive the email too).
I enclose a screenshot.
Hi jack19,
What debugging errors are you getting? It looks as though the email is being placed in the BCC of the email - but I can't tell for sure in from the information here.
Get the email working with one email first, then set it up to build a list of multiple emails. I think that setting a comma separated list will work OK.
Bob
What debugging errors are you getting? It looks as though the email is being placed in the BCC of the email - but I can't tell for sure in from the information here.
Get the email working with one email first, then set it up to build a list of multiple emails. I think that setting a comma separated list will work OK.
Bob
Hi GreyHead,
maybe this error:
I set the comma separated list like:
The main mistake is that email does not sending.
I plugged in the dynamic field BCC 'email_to_use', but appears always just an email address even though I have selected 3 with the check box.
Rgds
maybe this error:
Errors
Array
(
)
I set the comma separated list like:
'mail1' => 'mail1 @[at] gmail [dot] com,',
'mail2' => 'mail2 @[at] outlook [dot] it,',
'mail3' => 'netwxxxxxx @[at] xxxi [dot] it,' );
The main mistake is that email does not sending.
I plugged in the dynamic field BCC 'email_to_use', but appears always just an email address even though I have selected 3 with the check box.
Rgds
Hi John,
The empty Errors array just tells you that there were no errors to report.
It looks to me as though the netxxxx. . . email is being set in the BCC box of the email correctly. A bit hard to see as you crossed it out.
Bob
The empty Errors array just tells you that there were no errors to report.
It looks to me as though the netxxxx. . . email is being set in the BCC box of the email correctly. A bit hard to see as you crossed it out.
Bob
Hi John,
The empty Errors array just tells you that there were no errors to report.
It looks to me as though the netxxxx. . . email is being set in the BCC box of the email correctly. A bit hard to see as you crossed it out.
Bob
Hi GreyHead,
Tank You for reply.
But still I can not understand why the mail is not sent.
Although, I wish if I select three checkboxes, the email is sent to three addresses, but is not sent to anyone. 😢
Rgds
Hi GreyHead,
I have news, perhaps ugly.
I removed the action to send the email, creating one from scratch, in Basic mode.
In advanced is all empty.
I typed in the fields required values for sending in Basic mode but not sent any email.
Why?
🙄
I have news, perhaps ugly.
I removed the action to send the email, creating one from scratch, in Basic mode.
In advanced is all empty.
I typed in the fields required values for sending in Basic mode but not sent any email.
Why?
🙄
Hi GreyHead,
tank you very much.
now in Basic mode the email is sent,
but in the advanced in any field I enter email_to_use the email is not delivered, It is delivered to recipients only basic mode.
Rgds
tank you very much.
now in Basic mode the email is sent,
but in the advanced in any field I enter email_to_use the email is not delivered, It is delivered to recipients only basic mode.
Rgds
Hi GreyHead,
in part I understand, in the tutorial it says:
c) ..... Email action with the Dynamic To set to email_to_use It is enabled .....
I understand now that it was written so: {email_to_use}.
Now the problem is if I have more than one checkbox selected as I send to multiple recipients?
Rgds
in part I understand, in the tutorial it says:
c) ..... Email action with the Dynamic To set to email_to_use It is enabled .....
I understand now that it was written so: {email_to_use}.
Now the problem is if I have more than one checkbox selected as I send to multiple recipients?
Rgds
Hi Gioacchino,
To send to several addresses the value of e.g. email_to_use needs to be a comma separated string of addresses (with no spaces) e.g. john@domain1.com,alice@domain2.org,giorgio@some_other_domain.net
Bob
To send to several addresses the value of e.g. email_to_use needs to be a comma separated string of addresses (with no spaces) e.g. john@domain1.com,alice@domain2.org,giorgio@some_other_domain.net
Bob
Hi GreyHead,
thanks for the reply.
For now the situation is this:
in practice [recipients] reads all the values selected by checkboxes (mail1, mail2, mail3), but [email_to_use] always takes the last value passed by the checkbox (eg mail3 =myaddress_mail3@gmail.com).
Rgds
thanks for the reply.
For now the situation is this:
Array
(
[option] => com_chronoforms5
[chronoform] => Richiesta
[event] => submit
[dataarrivo] => 25-09-2015
[datapartenza] => 30-09-2015
[adulti] => 4
[bambini] => 0
[animali] => 0
[nome] => Pippo Franco
[email] => pippo.franco@gmail.com
[telefono] => 0123456789
[note] =>
[recipients] => mail1,mail2,mail3
[localita] => 1,2,3,4,5,6,7,8
[button9] => Submit
[email_to_use] => myaddress_mail3@gmail.com,
[ip_address] => ::1
)
Array
(
)
Errors
Array
(
)
Debug Info
Array
(
[27] => Array
(
[Email] => Array
(
[0] => An email with the details below was sent successfully:
[1] => To:, cms@joomla.org
[2] => Subject:Invio mail
[3] => From name:CMS Joomla
[4] => From email:mynameis@pippo.it
[5] => CC:
[6] => BCC:myaddress_mail3@gmail.com,
[7] => Reply name:
[8] => Reply email:
[9] => Attachments:
[10] => Array
(
)
[11] => Body:
<table>
<tr><td>Disponibilità </td><td></td>......
in practice [recipients] reads all the values selected by checkboxes (mail1, mail2, mail3), but [email_to_use] always takes the last value passed by the checkbox (eg mail3 =myaddress_mail3@gmail.com).
Rgds
Hi Gioacchino,
The code has to be changed a bit to build the list that you need. It will be something like this:
Bob
The code has to be changed a bit to build the list that you need. It will be something like this:
<?php
// set a default recipient
$recipient = 'mail1';
if ( isset($form->data['recipients']) && $form->data['recipients'] ) {
$recipient = explode(',', $form->data['recipients']);
}
$emails = array (
'mail1' => 'mail1 @[at] gmail [dot] com',
'mail2' => 'mail2 @[at] outlook [dot] it',
'mail3' => 'netwxxxxxx @[at] xxxi [dot] it'
);
$emails = array();
foreach ( $recipients as $r ) {
$emails[] = $emails[$r];
}
$form->data['email_to_use'] = implode(',', $emails);
?>
Bob
Hi Bob,
Now:
I also modified by
To
but it does not work. 😢
Rgds
Now:
[recipients] => mail1;mail2;mail3
[localita] => 1,2,3,4,5,6,7,8
[button9] => Submit
[email_to_use] =>
[ip_address] => ::1
I also modified by
foreach ( $recipients as $r ) {
To
foreach ( $recipient as $r ) {
but it does not work. 😢
Rgds
Hi Gioacchino,
This has the 's' on the end but the separator has changed from a comma to a semi-colon.
Bob
This has the 's' on the end but the separator has changed from a comma to a semi-colon.
[recipients] => mail1;mail2;mail3,
Bob
This topic is locked and no more replies can be posted.