// Now we know $key is valid, we can assign it // We use a helper to assist us in the different use cases we can // encounter where the type of input we want to create gives as the value in a format // different than we want to store (e.g. Checkbox gives 'on' and we want to store 1) $value_inserted = DbConversor::convert($form_field->getTypeString(), $var); $response->{$key} = $value_inserted; // We also add it to our parameters array for it to be send to the contact by // e-mail $parameters['fields'][$key] = $value_inserted; // And the field names $parameters['field_names'][$key] = $form_field->field_name; } $response->save(); // Aaaand, we send emails to all the contacts of that form $twig = $app->view()->getEnvironment(); // twig environment $transport = Swift_MailTransport::newInstance(); // Create the Mailer using your created Transport $mailer = Swift_Mailer::newInstance($transport); $parameters['form'] = $form; foreach ($contacts as $contact) { // Contact to be accessible from the template $parameters['contact'] = $contact; $generator = new Email($twig); $message = $generator->getMessage(Config::read('email_template'), $parameters); $message->setTo($contact->contact_email); $message->setFrom(Config::read('email_from')); $mailer->send($message); } $app->redirect($form->redirect); });