function hook_mail_safety_pre_insert in Mail Safety 7
Same name and namespace in other branches
- 8 mail_safety.api.php \hook_mail_safety_pre_insert()
- 7.2 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 16 - Hooks provided by the Mail Safety module.
Code
function hook_mail_safety_pre_insert($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;
}