Add attachments to elgg_send_email ?

Hi Everyone,

How can I add ElggFile as attachments to elgg_send_email ?

Here is my sample code.

$options = [
   'relationship' => 'xxxxxxxxxxxxx',
   'relationship_guid' => 'yyyyyyy',
   'owner_guid' => 'zzzzzz',
   'inverse_relationship' => true,
   'count' => true,
   'limit' => false,

$count = elgg_get_entities($options);


   $params = array();
   $document = elgg_get_entities($options);
   foreach ($document as $doc) {
      $params['attachments'][] = $doc;

   $options = [
      'to' => $value,
      'subject' => $subject,
      'body' => $body,
      'attachments' => $params,



The message is send, but the attachments are not sent. When I replace  elgg_send_email by notify_user ? everything works as expected and the attachments are sent.
Could someone help me ?
Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking