Attach file to email I have a site with a webform, which when submitted sends an email. The form has a file upload which should then attach the file as an attachment to the email. I'm not getting any attachment. 

I've created a hook for hook_mail_alter and tried hardcoding any attachment to be sent but every email i get has no attachment.

function my_module_mail_alter(&amp;$message) {
  $file_content = file_get_contents('sites/default/files/tmp/test.pdf');
  $message["params"]["attachments"] = array(
    'filecontent' =&gt; $file_content,
    'filename' =&gt; 'test.pdf',
    'filemime' =&gt; 'application/pdf'
  );
}


I've debugged the MailManager.php just before the email is sent and the $message variables param['attachement'] has the valid contents from the code above.

I've instaled modules: SMTP (so i can send emails from my local), MimeMail and enabled MailSystem The emails are being sent without any issue, but again never with an attachement.

I don't know what i'm doing wrong, any ideas?

Core: 8.6
Here's the answer, which is just an extension on the comment from @berramou

$file = file_load($fid);
  $message["params"]["attachments"][] =[
    'filepath' =&gt; $file-&gt;getFileUri(),
    'filemime' =&gt; '' // argument must be present, but can remain empty
  ];
}