KScript docs
EN

Mail: KScript.Mail

Queued mail

Talking to a mail server takes a moment, and a page shouldn't wait for it. Add queue, and the message goes on a queue for kscript worker to send:

<import package="KScript.Mail" />

<do>@send_mail(to: 'joan@example.com', subject: 'Welcome', view: 'mail/welcome', data: { name: 'Joan' }, queue)</do>
import KScript.Mail

@send_mail(to: 'joan@example.com', subject: 'Welcome', view: 'mail/welcome', data: { name: 'Joan' }, queue)

The view is rendered when you call @send_mail, so the worker sends exactly what you made. The message goes on config.mail.queue of the project's default queue connection, and is tried three times before it counts as failed (kscript queue failed lists it). On the sync connection, which tests use, it is sent at once.