Contact form with visible email address

Hi there,
I use the simple Kirby contact form for my homepage (see the following code). When a visitor sends me a message, I don’t see their email address in the message. Only when I answer does the address appear in the corresponding field. How can I make the sender address already visible in the message? What part of the code do I need to change?

Thanks and best regards!

<?php snippet('header') ?>
    <main class="main">
        <h1><?= $page->title()->html() ?></h1>

        <?php if($success): ?>
        <div class="alert success">
            <p><?= $success ?></p>
        <?php else: ?>
        <?php if (isset($alert['error'])): ?>
            <div><?= $alert['error'] ?></div>
        <?php endif ?>
        <form method="post" action="<?= $page->url() ?>">
            <div class="honeypot">
                <label for="website">Website <abbr title="required">*</abbr></label>
                <input type="url" id="website" name="website" tabindex="-1">
            <div class="field">
                <label for="name">
                    Name <abbr title="required">*</abbr>
                <input type="text" id="name" name="name" value="<?= esc($data['name'] ?? '', 'attr') ?>" required>
                <?= isset($alert['name']) ? '<span class="alert error">' . esc($alert['name']) . '</span>' : '' ?>
            <div class="field">
                <label for="email">
                    Email <abbr title="required">*</abbr>
                <input type="email" id="email" name="email" value="<?= esc($data['email'] ?? '', 'attr') ?>" required>
                <?= isset($alert['email']) ? '<span class="alert error">' . esc($alert['email']) . '</span>' : '' ?>
            <div class="field">
                <label for="text">
                    Text <abbr title="required">*</abbr>
                <textarea id="text" name="text" required>
                    <?= esc($data['text'] ?? '') ?>
                <?= isset($alert['text']) ? '<span class="alert error">' . esc($alert['text']) . '</span>' : '' ?>
            <input type="submit" name="submit" value="Submit">
        <?php endif ?>

<?php snippet('footer') ?>

I think the email variable is hidden in the default template and only shown in the ReplyTo-Header, as you experience it.

You could either rename it to something different, e.g. emailadress to have it shown in the default template or create your own email template with the email adresse included: Email contact form | Kirby CMS

Thank you! I try it out!

In /site/controllers/contact.php in the last line of the following code snippet I added


// the data is fine, let's send the email
        } else {
            try {
                    'template' => 'email',
                    'from'     => esc($site->email()),
                    'replyTo'  => $data['email'],
                    'to'       => esc($site->email()),
                    'subject'  => esc($data['name']) . ' ' . esc($site->labelEmailSubject()->or('sent you a message from your contact form')),
                    'data'     => [
                        'text'   => esc($data['text']),
                        'sender' => esc($data['name']),
						'email'  => esc($data['email'])


<?= $email ?>

in email.html.php and email.php

It works well! Thanks for your suggestions!