$kirby->email()
Returns the Email singleton
$kirby->email(mixed $preset = [ ], array $props = [ ]): Kirby\Email\Email
Parameters
Name | Type | Default |
---|---|---|
$preset | mixed |
[ ] |
$props | array |
[ ] |
Return type
Parent class
Examples
Basic example
try {
$kirby->email([
'from' => '[email protected]',
'replyTo' => '[email protected]',
'to' => '[email protected]',
'cc' => '[email protected]',
'bcc' => '[email protected]',
'subject' => 'Welcome!',
'body'=> 'It\'s great to have you with us',
]);
} catch (Exception $error) {
echo $error;
}
from
& replyTo
'from' => 'no-[email protected]',
'replyTo' => '[email protected]'
from
with name
'from' => '[email protected]',
'fromName' => 'Jane Doe'
from
with user object
$from = new \Kirby\Cms\User([
'email' => '[email protected]',
'name' => 'Jane Doe',
]);
'from' => $from,
replyTo
with name
'replyTo' => '[email protected]',
'replyToName' => 'Jane Doe'
to
, cc
and bcc
Single recipient
'to' => '[email protected]',
'cc' => '[email protected]',
'bcc' => '[email protected]',
Single recipient with name
'to' => ['[email protected]', 'Super Company'],
Multiple recipients
'to' => [
'[email protected]',
'[email protected]'
],
Collection of users
$kirby->email([
'to' => $kirby->users()->role('newbies'),
'cc' => $kirby->users()->role('members')
]);
Multiple recipients with name
'to' => [
['j[email protected]', 'Jane Doe'],
['[email protected]', 'Mark Otto']
],
'cc' => [
['j[email protected]', 'Jane Doe'],
['[email protected]', 'Mark Otto']
],