You are here

function hook_mail_safety_pre_insert in Mail Safety 8

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

Respond to a mail being inserted to the dashboard.

Parameters

array $message: The message array.

Return value

array Return the message array after any changes.

File

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

Code

function hook_mail_safety_pre_insert(array $message) {

  // Check to see if there are attachments.
  if (!empty($message['params']['attachments'])) {

    // Loop through the attachments and save the files.
    foreach ($message['params']['attachments'] as $key => $attachment) {
      $file = file_save_data($attachment['content'], 'public://' . time() . '-' . $attachment['filename']);
      $message['attachments'][$key] = $file;
    }

    // Remove the attachments from the e-mail.
    unset($message['params']['attachments']);
  }
  return $message;
}