add mms files to mail transfert

This commit is contained in:
osaajani 2021-04-03 18:19:08 +02:00
parent d29424ff0c
commit e06079e6af
5 changed files with 17 additions and 5 deletions

View file

@ -101,10 +101,11 @@ class Mailer extends \descartes\Controller
* @param string $destination : email address to send email to
* @param array $settings : Email settings
* @param array $data : Data to inject into email template
* @param array $attachments : List of paths of files to attach to the mail
*
* @return bool : true on success, false on error
*/
public function enqueue(string $destination, array $settings, array $data): bool
public function enqueue(string $destination, array $settings, array $data, array $attachments = []): bool
{
$response = $this->generate_body($settings, $data);
@ -113,6 +114,7 @@ class Mailer extends \descartes\Controller
'subject' => $settings['subject'],
'body' => $response['body'],
'alt_body' => $response['alt_body'],
'attachments' => $attachments,
];
$error_code = null;

View file

@ -291,12 +291,20 @@ namespace controllers\internals;
}
$mailer = new Mailer();
$attachments = [];
foreach ($received['medias'] ?? [] as $media)
{
$attachments[] = PWD_DATA_PUBLIC . '/' . $media['path'];
}
return $mailer->enqueue($user['email'], EMAIL_TRANSFER_SMS, [
'at' => $received['at'],
'origin' => $received['origin'],
'destination' => $phone['name'],
'text' => $received['text'],
]);
'mms' => $received['mms'] ?? false,
], $attachments);
}
}