You are here

function hook_mail_safety_pre_send in Mail Safety 8

Same name and namespace in other branches
  1. 7.2 mail_safety.api.php \hook_mail_safety_pre_send()
  2. 7 mail_safety.api.php \hook_mail_safety_pre_send()

Respond to a mail before it is being send.

Parameters

array $message: The message array.

Return value

array Return the message array after any changes.

2 invocations of hook_mail_safety_pre_send()
SendDefaultForm::submitForm in src/Form/SendDefaultForm.php
Form submission handler.
SendOriginalForm::submitForm in src/Form/SendOriginalForm.php
Form submission handler.

File

./mail_safety.api.php, line 56
Hooks provided by the Mail Safety module.

Code

function hook_mail_safety_pre_send(array $message) {

  // Loop through the attachments in a message.
  foreach ($message['attachments'] as $key => $attachment) {

    // Return the attachment to the e-mail to send it again.
    $message['params']['attachments'][$key] = [
      'content' => file_get_contents($attachment->uri),
      'mime' => $attachment->filemime,
      'filename' => $attachment->filename,
    ];
  }
  return $message;
}