Formit different emailTo with different emailtpls

Hello,

I have a formit form and i have to send email 2 different emails using 2 different email tpls with the form values.

The issue is that the formit allows you to set one or more emailtpls but all the recipients will receive the same email.

What i want is:
useremail@useremail.com to receive contents from emailtpl1
and
adminemail@adminemail.com to receive contents from emailtpl2

I’ve tried to use a snippet to return the chunk but the form values are not filled it is just showing the placeholders (see pic below)

My current snippet code is calling the chunk used to the emailtpl in formit
<?php
$to = "adminemail@adminemail.com";
$subject = “CyprusArt - New Testimony”;

$message = $modx->getChunk('AnonymousTestimonyFormEmailChunk');

// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

// More headers
// $headers .= 'Cc: test@test.com' . "\r\n";

mail($to,$subject,$message,$headers);

Pls remove those emails from your code, just for safety.

Can you give us your formit call? Those headers look like you will always get that cc to your gmail

I found a solution. i called my chunk like this
$modx->getChunk(‘AdminEmailChunkTpl’, $allFormFields);

1 Like

Great, you are a pro by now!