email($params)

Sends an email

  • $params (array)
  • return ($email)

Example

$email = email(array(
  'to'      => 'bastian@getkirby.com',
  'from'    => 'my@email.com',
  'subject' => 'Sending emails with Kirby is easy',
  'body'    => 'Hey! This was really easy!'
));

if($email->send()) {
  echo 'The email has been sent';
} else {
  echo $email->error();
}

Set email options

You can set default email options in your config.php

c::set('email.service', 'mail');
c::set('email.from', 'Bastian Allgeier <bastian@getkirby.com>');
c::set('email.replyTo', 'Bastian Allgeier <bastian@getkirby.com>');
c::set('email.subject', 'Kirby Support');

You can then send emails in your templates, controllers, snippets etc. with those default settings:

email()->send([
  'to'   => 'peter@example.com',
  'body' => 'Hey Peter!'
]);

Is something missing or incorrect? Edit this page on Github…