Multiplier field - configure sending e-mail

jaak 17 Aug, 2016
I setup form for invitations with multiplier field to send birthday invitations (http://adplus.ee/arendus/lohesaba/invitation)

Form should send e-mails to all persons inserted trough multiplier field (name, e-mail).

How can I configure that?
GreyHead 18 Aug, 2016
Hi Jaak,

I think that if you convert the array of email addresses to a comma separated list then you can use that in the Dynamic To box of the Email action. There was a similar question a few months ago and I believe that was the solution.

Bob
jaak 06 Sep, 2016
Hello,

I found that topic, but unfortunately this is not exatcly what I need. The multiplier field array looks like this below and I need to send personal e-mail to each person in an array. Therefore I need to put each person data into e-mail template (+ other form data), form nicely formated e-mail (picture background and send it to the this person). And repeat this process how many recipients I have. Example below should create two personal e-mails.

 [kylaline] => Array
        (
            [1] => Array
                (
                    [nimi] => First Person
                    [epost] => first.person@gmail.com
                )

            [2] => Array
                (
                    [nimi] => Second Person
                    [epost] => second.person@gmail.com
                )

        )
jaak 08 Sep, 2016
Example code from post working as expected http://www.chronoengine.com/forums/posts/f5/t101072/handle-subarray.html?hilit=multiplier. But it creates one e-mail which was sent to multiple addresses but I want multiple e-mails with dynamic data sent to different address. I'm modified the code and as expected it sends e-mail only to the last e-mail from multiplier array.

Is where possibility to add code that will call e-mail action from custom php code and then last element of multiplier array was processed disables e-mail action.

<?php
$form->data['kylaline_nimi'] = array();
$form->data['kylaline_epost'] = array();
foreach ( $form->data['kylaline'] as $a ) {
    $form->data['kylaline_nimi'] = $a['nimi'];
    $form->data['kylaline_epost'] = $a['epost'];

//How can call from here suitable e-mail action

}

?>
GreyHead 18 Nov, 2016
Hi jaak,

My apologies for the very very late reply,

The CFv5 email action doesn't support individual emails :-(

The way to do this is to use a Custom Code action to loop through the list of addresses and send one email each time using the Joomla! mail code.

Bob
jaak 02 Dec, 2016
1 Likes
Hello,

I found the way. Maybe useful for someone:
<?php
// Get Joomla e-mail
$mailer = JFactory::getMailer();
// Set HTML
$mailer->isHTML();
// Set from
$from = array($form->data['text16'], $some_form_data);
$mailer->setSender($from);
//Set subject
$subject = 'Subject text - '.$form->data['text13'];
$mailer->setSubject($subject);
//Process multiplier data and add them into e-mail body

foreach ( $form->data['quest'] as $a ) {
	
//Set variables
	$form->data['quest_name']='';
	$form->data['quest_email'] = '';
//Extract multiplier data one by one
    $form->data['quest_name'] = $a['name'];
	$form->data['quest_email'] = $a['email'];	
//HTML e-mail content with variables from form

$htmlContent = 'Your HTML template';

//Add recipient e-mail address
$mailer->clearAllRecipients(); //without this statement every loop iteration adds not substitutes recipient
$mailer->addRecipient($form->data['quest_email']);

//Add HTML body
$mailer->setBody($htmlContent);
//Send
$mailer->send();
}
?>
This topic is locked and no more replies can be posted.