026: Email contact form
A contact form whose server action sends an email through the configured email provider and shows the result message in a panel on the page.
What this demonstrates
- The default stdout email provider, used automatically in dev mode when no
WithEmailProvideroption is registered (rendered email appears in the server terminal). - An email template as a PK file with a Go
Renderfunction that receives typed props and returns metadata (and optionally a response struct); the email body is the rendered<template>block. - A server action that builds and sends emails via
email.NewTemplatedEmailBuilderFromDefault[Props]()then.To(...).Subject(...).BodyTemplate(...).Props(...).Do(ctx)frompiko.sh/piko/wdk/email. - The email dispatcher queue, which retries failed sends.
Project structure
src/
cmd/main/main.go Bootstrap with the email provider.
pages/
index.pk The contact form page.
emails/
confirmation.pk Template sent to the submitter.
notification.pk Template sent to the site owner.
actions/
contact/
send.go Validates input, renders the templates, sends both emails.
How to run this example
From the Piko repository root:
cd examples/scenarios/026_email_contact/src/
go mod tidy
air
Submit the form on the index page. The scenario prints captured email output to the console, or delivers through whichever provider the scenario uses.