To send a confirmation email, you’ll need to define specific fields in your blueprint and add a template for the email content. Follow these steps to set it up seamlessly.
To send an email to the form user, you’ll need the following fields in your blueprint:
type: email and the attribute reply: true. This tells the plugin to use the value entered here as the recipient for the reply email.username: true.fields:
name:
type: text
label: Name
placeholder: Your name
required: true
username: true
email:
type: email
label: Email
placeholder: Your Email
required: true
reply: true
replyto: true
Next, create a reply.text.php file in your template folder. This file will define the content of the email sent to the form user.
Learn more about the file structure here.
Hello <?= $form->name() ?>,
thanks for your email. We will get back to you soon.
Here is the information provided by you:
<?php foreach ($form->toArray() as $field): ?>
<?= $field->key() . ': ' . $field->value() . "\n\n" ?>
<?php endforeach; ?>
Have a great day.
<?php if($email->footer()->isNotEmpty()): ?>
---
<?= $email->footer() ?>
<?php endif; ?>
With these steps, your form will automatically send confirmation emails to the user, including their submitted data. This improves user experience and ensures they have a copy for their records. Want to customize further? Add an HTML template (reply.html.php) for richer formatting.