March 2019
Intermediate to advanced
580 pages
15h 3m
English
As I mentioned earlier, the first step for sending mails in Drupal 8 is implementing hook_mail(). In our case, it can look something like this:
/** * Implements hook_mail(). */function hello_world_mail($key, &$message, $params) { switch ($key) { case 'hello_world_log': $message['from'] = \Drupal::config('system.site')->get('mail'); $message['subject'] = t('There is an error on your website'); $message['body'][] = $params['message']; break; }}
This hook receives three parameters:
As you can see, we are defining a key (or template) named hello_world_log, which ...
Read now
Unlock full access