KScript docs
EN

fake_mail fields and methods

A field is a plain fact about the value, read with a dot and no brackets: $value.name. A method takes arguments or does work, and is called with ->: $value->name(arguments), or with the value piped in: $value |> name(arguments).

From KScript.Mail

These need <import package="KScript.Mail" />import KScript.Mail. See KScript.Mail.

#fake_mail->clear() → number KScript.Mail

Forgets the mail sent so far, and returns how many there were.
Example
<let name="mail" value="@fake_mail()" />
<echo>{ $mail->clear() }</echo>
$mail = @fake_mail()
echo $mail->clear()

#fake_mail->count() → number KScript.Mail

How many messages were sent.
Example
<let name="mail" value="@fake_mail()" />
<echo>{ $mail->count() }</echo>
$mail = @fake_mail()
echo $mail->count()

#fake_mail->count_of(to) → number KScript.Mail

How many messages went to one address (or user).
Example
<let name="mail" value="@fake_mail()" />
<do>@send_mail(to: ['joan@example.com', 'ada@example.com'], subject: 'Hi', text: 'Hello')</do>
<echo>{ $mail->count_of('ada@example.com') }</echo>
$mail = @fake_mail()
@send_mail(to: ['joan@example.com', 'ada@example.com'], subject: 'Hi', text: 'Hello')
echo $mail->count_of('ada@example.com')

#fake_mail->has_sent(to) → bool KScript.Mail

True when mail went to the address (or user), as to, cc or bcc.
Example
<let name="mail" value="@fake_mail()" />
<echo>{ $mail->has_sent('joan@example.com') }</echo>
$mail = @fake_mail()
echo $mail->has_sent('joan@example.com')

#fake_mail->queued(to?) → list KScript.Mail

The mail that was sent with queue, or only the mail to one address.
Example
<let name="mail" value="@fake_mail()" />
<do>@send_mail(to: 'joan@example.com', subject: 'Hi', text: 'Hello', queue)</do>
<echo>{ $mail->queued()->count() } queued</echo>
$mail = @fake_mail()
@send_mail(to: 'joan@example.com', subject: 'Hi', text: 'Hello', queue)
echo "{ $mail->queued()->count() } queued"

#fake_mail->sent(to?) → list KScript.Mail

The mail sent so far, queued or not, or only the mail to one address (or user): each a map of to, cc, bcc, from, reply_to, subject, html, text, view, attachments and is_queued.
Example
<let name="mail" value="@fake_mail()" />
<do>@send_mail(to: 'joan@example.com', subject: 'Hi', text: 'Hello')</do>
<echo>{ $mail->sent('joan@example.com')[0].subject }</echo>
$mail = @fake_mail()
@send_mail(to: 'joan@example.com', subject: 'Hi', text: 'Hello')
echo $mail->sent('joan@example.com')[0].subject

Methods from any