Kirby

How to modify the email contact form to use Panel fields values?

Hello,

1. Is this correct if I want to set the values from the Panel?

$kirby->email([
    'template' => 'email',
    'from'     => $page->fromEmail()->value(), // field from Panel
    'replyTo'  => $data['email'],
    'to'       => $page->toEmail()->value(), // field from Panel
    'subject'  => esc($data['name']) . $page->subject()->value() . '.', // field from Panel
    'data'     => [
        'text'   => esc($data['text']),
        'sender' => esc($data['name'])
    ]
]);

2. If I want to send an autoreply, is this how to do it? And how can I make it so the from, subject, cc, and body will be set in the Panel?

site/config/config.php

'email' => [
    'presets' => [
      'autoreply' => [
        'from'    => 'no-reply@supercompany.com',
        'subject' => 'Thank you for your contact request',
        'cc'      => 'marketing@supercompany.com',
        'body'    => 'We will never reply'
      ]
    ]
  ]

site/controllers/contact.php

$kirby->email([
  'template' => 'email',
  'from'     => $page->fromEmail()->value(), // field from Panel
  'replyTo'  => $data['email'],
  'to'       => $page->toEmail()->value(), // field from Panel
  'subject'  => esc($data['name']) . $page->subject()->value() . '.', // field from Panel
  'data'     => [
    'text'   => esc($data['text']),
    'sender' => esc($data['name'])
  ]
]);

$kirby->email('autoreply', [
  'to' => $data['email']
]);

I would like to configure the contact form so all details will be set by the user in the Panel. Especially that it is a multilanguage website. Reply messages and subject must be translatable.