Skip to content

Instantly share code, notes, and snippets.

@rpayanm
Created December 12, 2019 14:02
Show Gist options
  • Save rpayanm/99f85605ea377983693642cfc236f3d7 to your computer and use it in GitHub Desktop.
Save rpayanm/99f85605ea377983693642cfc236f3d7 to your computer and use it in GitHub Desktop.
<?php
/**
* Implements hook_mail().
*/
function MY_MODULE_mail($key, &$message, $params) {
if ($key == 'MY_KEY') {
$fid = 4; // For example
$file = File::load($fid);
$message['params']['attachments'][] = [
'filename' => $file->getFilename(),
'filepath' => $file->getFileUri(),
'filemime' => $file->getMimeType(),
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment