Uniform’s Email Action: Can I add a page title or other fields to the body?

I’m using Uniform for the first time, and not changing much. It’s working well and sending my form’s three fields via email, using an email template for the body. (Easy plugin!)

It’s crucial that the resulting email sends the title of the page — they are requests for specific reports. After adding $page to the return function, I’m able to get the $page->title() in the subject option of the Email Action.

controllers/report.php [excerpt]

	if ($kirby->request()->is('POST')) {
		$form->emailAction([
			'to' => 'request@client.com',
			'from' => 'info@client.com',
			'subject' => 'Report Request: ' . $page->title(),
			'template' => 'report'
		])->done();

Now is there any way to add the title to the body as well? I think I can convey information in a hidden form field, but that’s not ideal. And anything complex, like writing a custom action, is probably not worth the effort—or beyond my skills.

templates/emails/report.php

Somebody has requested this report:

GET TITLE AND/OR OTHER FIELDS FROM PAGE?

Name: <?= $name ?>
Company: <?= $company ?>
Email: <?= $email ?>

As it stands, the title is already being delivered. Still, I’m curious to know where to begin if I wanted to add $page information — not just the form values — to the email.

Thanks for any help.

Check out the docs here, in particular the part about body: Email - Kirby Uniform

Thanks. I’ve reread this page and used the Body option, rather than Template option to create the body text. I can pull in the page title, just as I did for the subject. But how much control over white space and lines breaks do I have here?

I’m guessing it’s some PHP that I need to learn? The template options makes the plain text line breaks easy, so I was hoping to still use one.

	if ($kirby->request()->is('POST')) {
		$form->emailAction([
			'to' => 'requests@client.com',
			'from' => 'info@client.com',
			'subject' => 'Report Request: ' . $page->title(),
			'body' => 	'A request has been submitted for: ' . $page->title() .
							
							'Name: {{name}}
							Company: {{company}}
							Email: {{email}}
							---
							This email was sent via a report form on your website.'

		])->done();
	}