Forums

sending email to different email adresses won't work!

mustiej 17 Mar, 2015
hey guys,

I have a problem. I need to give my school a presentation about sending a quote offer to multiple selected email adresses.

I found this but didn't work for me:http://www.chronoengine.com/faqs/52-cfv4/cfv4-emails/2603-how-can-i-send-an-email-to-different-addresses.html

I did this:

1. I made a checkbox group
field name and id = recipients
options is
Company 1 = myemail@email.com
Company 2 = myemail@email.nl

2. I made a custom code in page3(which is my last formpage(multi form page) before html (render form) which has submit event: submit in it with the following code:
<?php
// set a default recipient
$recipient = 'recipient@recipient.nl';
if ( isset($form->data['recipients']) && $form->data['recipients'] ) {
  $recipient = $form->data['recipients'];
}
$emails = array (
  'Company 1' => 'myemail@email.com',
  'Company 2' => 'myemail@email.nl');
$form->data['email_to_use'] = $emails[$recipient];
?>

3. in between custom code and html render form I have email event which i have already setup email from to etc and in advanced tab in dynamic to I have put in this: email_to_use

Just like in the link tutorial I did everything as they said, i think but it still doesn't work.

Another question is what is the best way to show a list of companies(company name, little description, user rating and an image) instead of the 2 emails to select upon. So depending on which company you select on page 3 it will send it's quote offer to them. Can I use yootheme's zoo module to show the company list in the chronoform's form?
GreyHead 17 Mar, 2015
Hi mustiej,

Your code looks OK, Please drag a Debugger action into the On Submit event, then submit the form and post the debug - including the 'dummy emails' results here.

I don't know anything about the Zoo module but I don't' think that you will be able to usefully show it in a ChronoForm. You can create a 'dynamic' list in various ways if the data is in a database table. The Select drop-down and Radio button group will accept dynamic data. But if you want to include images then you may need to use a Custom Code element to create the HTML.

Bob
mustiej 19 Mar, 2015
Hey Greyhead,

Sorry for the late reaction, somehow didn't got subcribed to this topic.
It sends to rvanes because it's the default recipient in email to field.

Array
(
    [14] => Array
        (
            [Email] => Array
                (
                    [0] => An email with the details below was sent successfully:
                    [1] => To:, rvanes@consurent.nl
                    [2] => Subject:Offerte aanvraag
                    [3] => From name:Ron van Es
                    [4] => From email:rvanes@consurent.nl
                    [5] => CC:
                    [6] => BCC:
                    [7] => Reply name:
                    [8] => Reply email:
                    [9] => Attachments:
                    [10] => Array
                        (
                        )

                    [11] => Body:
<table>
<tr><td>Naam:</td><td></td></tr>
<tr><td>Achternaam:</td><td></td></tr>
<tr><td>Email:</td><td></td></tr>
<tr><td></td><td></td></tr>
<tr><td>Kies uw product</td><td></td></tr>
<tr><td></td><td></td></tr>
<tr><td>Naar welke bedrijf wilt u een offerte aanvraag sturen?</td><td>Bedrijf 2</td></tr>
<tr><td></td><td></td></tr>
</table><br /><br />IP: 82.161.95.223
                )

        )

)
mustiej 19 Mar, 2015
The idea is to send to "bedrijf 1" and "bedrijf 2" because I have selected them in page 1.
But I only see Bedrijf 2 between td tags??
mustiej 19 Mar, 2015
Also the entire form is empty??
GreyHead 19 Mar, 2015
Hi mustiej,

Please post **all** of the Debugger output here.

Bob
mustiej 19 Mar, 2015
Data array:

Array
(
    [chronoform] => contactform
    [event] => submit
    [naam] => mustafa
    [achternaam] => tosuncu
    [email] => mustiej_70@hotmail.com
    [button6] => Stap 2
    [machines] => 1
    [button8] => Stap 3
    [recipients] => Bedrijf 2
    [button10] => Verstuur
    [email_to_use] => 
    [ip_address] => 82.161.95.223
)


Debug info:

Array
(
    [14] => Array
        (
            [Email] => Array
                (
                    [0] => An email with the details below was sent successfully:
                    [1] => To:, rvanes@consurent.nl
                    [2] => Subject:Offerte aanvraag
                    [3] => From name:Ron van Es
                    [4] => From email:rvanes@consurent.nl
                    [5] => CC:
                    [6] => BCC:
                    [7] => Reply name:
                    [8] => Reply email:
                    [9] => Attachments:
                    [10] => Array
                        (
                        )

                    [11] => Body:
<table>
<tr><td>Naam:</td><td></td></tr>
<tr><td>Achternaam:</td><td></td></tr>
<tr><td>Email:</td><td></td></tr>
<tr><td></td><td></td></tr>
<tr><td>Kies uw product</td><td></td></tr>
<tr><td></td><td></td></tr>
<tr><td>Naar welke bedrijf wilt u een offerte aanvraag sturen?</td><td>Bedrijf 2</td></tr>
<tr><td></td><td></td></tr>
</table><br /><br />IP: 82.161.95.223
                )

        )

)


This is all, I feel like I have done something completely wrong 😲
GreyHead 23 Mar, 2015
Hi musteij,

The value of 'recipients' in the form data is ' [recipients] => Bedrijf 2' but the Custom Code only has emails set for 'Company 1' and 'Company 2' there is nothing there for 'Bedrijf 2':
$emails = array (
  'Company 1' => 'myemail @[at] email [dot] com',
  'Company 2' => 'myemail @[at] email [dot] nl'
);

Bob
mustiej 23 Mar, 2015
Hey Bob,

I forgot to mention that I changed the Custome code:
<?php
// set a default recipient
$recipient = 'rvanes@consurent.nl';
if ( isset($form->data['recipients']) && $form->data['recipients'] ) {
  $recipient = $form->data['recipients'];
}
$emails = array (
  'bedrijf 1' => 'rvanes@consurent.nl',
  'bedrijf 2' => 'mustiej_70@hotmail.com');
$form->data['email_to_use'] = $emails[$recipient];
?>
GreyHead 23 Mar, 2015
Hi mustiej,

That helps but 'Bedrijf 2' is not the same as 'bedrijf 2'. Please check your code carefully for consistency.

Bob
mustiej 26 Mar, 2015
Hey,
I managed to get it working but when I open the mail it has no value:
Naam:
Achternaam:
Email:
Kies uw product
Naar welke bedrijf wilt u een offerte aanvraag sturen? bedrijf 2

and in debug info:

Array
(
    [14] => Array
        (
            [Email] => Array
                (
                    [0] => An email with the details below was sent successfully:
                    [1] => To:mustiej_70@hotmail.com, rvanes@consurent.nl
                    [2] => Subject:Offerte aanvraag
                    [3] => From name:Ron van Es
                    [4] => From email:rvanes@consurent.nl
                    [5] => CC:
                    [6] => BCC:
                    [7] => Reply name:
                    [8] => Reply email:
                    [9] => Attachments:
                    [10] => Array
                        (
                        )

                    [11] => Body:
<table>
<tr><td>Naam:</td><td></td></tr>
<tr><td>Achternaam:</td><td></td></tr>
<tr><td>Email:</td><td></td></tr>
<tr><td></td><td></td></tr>
<tr><td>Kies uw product</td><td></td></tr>
<tr><td></td><td></td></tr>
<tr><td>Naar welke bedrijf wilt u een offerte aanvraag sturen?</td><td>bedrijf 2</td></tr>
<tr><td></td><td></td></tr>
</table><br /><br />IP: 82.161.95.223
                )

        )

)


array:

Array
(
    [chronoform] => contactform
    [event] => submit
    [naam] => Test 10
    [achternaam] => Test 12
    [email] => mustiej_70@hotmail.com
    [button6] => Stap 2
    [machines] => 1
    [button8] => Stap 3
    [recipients] => bedrijf 2
    [button10] => Verstuur
    [email_to_use] => mustiej_70@hotmail.com
    [ip_address] => 82.161.95.223
)
GreyHead 26 Mar, 2015
Hi mustiej,

What do you now have in the Email template?

Bob
mustiej 26 Mar, 2015
This is in the Email event: Email template
<table>
<tr><td>Naam:</td><td>{naam}</td></tr>
<tr><td>Achternaam:</td><td>{achternaam}</td></tr>
<tr><td>Email:</td><td>{email}</td></tr>
<tr><td>{label}</td><td>{progress_bar}</td></tr>
<tr><td>Kies uw product</td><td>{machines}</td></tr>
<tr><td>{label}</td><td>{progress_bar}</td></tr>
<tr><td>Naar welke bedrijf wilt u een offerte aanvraag sturen?</td><td>{recipients}</td></tr>
<tr><td>{label}</td><td>{progress_bar}</td></tr>
</table>
GreyHead 26 Mar, 2015
Hi mustiej,

You have several variables there that don't exist in the form data like {label} and {progress_bar} but I would expect the others to display correctly e.g. {naam}, {achternaam}

By all means email or PM me the site URL, the form name, and a SuperAdmin login and I'll take a quick look.

Bob
mustiej 27 Mar, 2015
I've sent the PM
This topic is locked and no more replies can be posted.