If you haven’t already, install the Email Manager plugin.
In your Kirby configuration file (site/config/config.php), set up the email transport. It’s recommended to use a noreply email address for sending emails.
Here’s an example configuration using an SMTP transport:
return [
'email' => [
'noreply' => 'no-reply@yourdomain.com'
'transport' => [
'type' => 'smtp',
'host' => 'smtp.server.com',
'port' => 465,
'security' => true,
'auth' => true,
'username' => 'SMTP_USERNAME',
'password' => 'SMTP_PASSWORD'
]
]
];
Don't store credentials directly in the production configuration. You can use the Kirby ENV Plugin to manage sensitive credentials like SMTP usernames and passwords.
You can also use one of the examples in the resources as a starting point.
Create the file site/blueprints/emails/contact-form.yml with the following content:
Or try the AI Schema to configure your Blueprint in an AI Chat.
type: managed-template
name: Contact Form
emails:
mail:
subject: Contact Form Submission
sender: Contact Form
fields:
name:
label: Name
placeholder: Enter your name
type: text
required: true
username: true
email:
label: Email
placeholder: Enter your email
type: email
required: true
replyto: true # let's you directly answer to the received mail
message:
label: Message
placeholder: Enter your message
type: textarea
resizable: vertical
rows: 6
required: true
minlength: 10
If you don't create custom templates, the plugin uses built-in default templates (mail + reply).
To customize, create the file site/templates/emails/contact-form/mail.txt.php with the content for your email:
From: <?= $form->email() ?>
Name: <?= $form->name() ?>
Message:
<?= $form->message() ?>
Create a blueprint file at site/blueprints/pages/contact.yml with the following content:
title: Contact Page
tabs:
email-manager: email-manager
Create a template file at site/templates/contact.php and add the following snippet:
<?php snippet('email-manager/form-wrapper'); ?>
In the Kirby panel, create a new page using the Contact Page blueprint. Once the page is created, select the Contact Form template. Enter the email address where you would like to receive messages sent through the form.
Additionally, provide a success title and message to inform users that their submission was successful.
Your contact form is now ready to use.