add mms files to mail transfert
This commit is contained in:
parent
d29424ff0c
commit
e06079e6af
|
@ -101,10 +101,11 @@ class Mailer extends \descartes\Controller
|
||||||
* @param string $destination : email address to send email to
|
* @param string $destination : email address to send email to
|
||||||
* @param array $settings : Email settings
|
* @param array $settings : Email settings
|
||||||
* @param array $data : Data to inject into email template
|
* @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
|
* @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);
|
$response = $this->generate_body($settings, $data);
|
||||||
|
|
||||||
|
@ -113,6 +114,7 @@ class Mailer extends \descartes\Controller
|
||||||
'subject' => $settings['subject'],
|
'subject' => $settings['subject'],
|
||||||
'body' => $response['body'],
|
'body' => $response['body'],
|
||||||
'alt_body' => $response['alt_body'],
|
'alt_body' => $response['alt_body'],
|
||||||
|
'attachments' => $attachments,
|
||||||
];
|
];
|
||||||
|
|
||||||
$error_code = null;
|
$error_code = null;
|
||||||
|
|
|
@ -292,11 +292,19 @@ namespace controllers\internals;
|
||||||
|
|
||||||
$mailer = new Mailer();
|
$mailer = new Mailer();
|
||||||
|
|
||||||
|
$attachments = [];
|
||||||
|
|
||||||
|
foreach ($received['medias'] ?? [] as $media)
|
||||||
|
{
|
||||||
|
$attachments[] = PWD_DATA_PUBLIC . '/' . $media['path'];
|
||||||
|
}
|
||||||
|
|
||||||
return $mailer->enqueue($user['email'], EMAIL_TRANSFER_SMS, [
|
return $mailer->enqueue($user['email'], EMAIL_TRANSFER_SMS, [
|
||||||
'at' => $received['at'],
|
'at' => $received['at'],
|
||||||
'origin' => $received['origin'],
|
'origin' => $received['origin'],
|
||||||
'destination' => $phone['name'],
|
'destination' => $phone['name'],
|
||||||
'text' => $received['text'],
|
'text' => $received['text'],
|
||||||
]);
|
'mms' => $received['mms'] ?? false,
|
||||||
|
], $attachments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ class Mailer extends AbstractDaemon
|
||||||
$this->logger->info('Try sending email : ' . json_encode($message));
|
$this->logger->info('Try sending email : ' . json_encode($message));
|
||||||
|
|
||||||
$mailer = new \controllers\internals\Mailer();
|
$mailer = new \controllers\internals\Mailer();
|
||||||
$success = $mailer->send($message['destinations'], $message['subject'], $message['body'], $message['alt_body']);
|
$success = $mailer->send($message['destinations'], $message['subject'], $message['body'], $message['alt_body'], $message['attachments']);
|
||||||
if (!$success)
|
if (!$success)
|
||||||
{
|
{
|
||||||
$this->logger->error('Failed sending email');
|
$this->logger->error('Failed sending email');
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
'PWD_ADAPTERS' => PWD . '/adapters',
|
'PWD_ADAPTERS' => PWD . '/adapters',
|
||||||
'PWD_DATA' => PWD . '/data',
|
'PWD_DATA' => PWD . '/data',
|
||||||
'HTTP_PWD_DATA' => HTTP_PWD . '/data',
|
'HTTP_PWD_DATA' => HTTP_PWD . '/data',
|
||||||
|
'PWD_DATA_PUBLIC' => PWD . '/data/public',
|
||||||
|
'HTTP_PWD_DATA_PUBLIC' => HTTP_PWD . '/data/public',
|
||||||
'PWD_LOGS' => '/var/log/raspisms',
|
'PWD_LOGS' => '/var/log/raspisms',
|
||||||
'PWD_PID' => '/var/run/raspisms',
|
'PWD_PID' => '/var/run/raspisms',
|
||||||
'APP_SECRET' => '%APP_SECRET%',
|
'APP_SECRET' => '%APP_SECRET%',
|
||||||
|
@ -67,7 +69,7 @@
|
||||||
'preferred_phone_country' => 'fr,be,ca',
|
'preferred_phone_country' => 'fr,be,ca',
|
||||||
'default_phone_country' => 'fr',
|
'default_phone_country' => 'fr',
|
||||||
'authorized_phone_country' => 'fr,be,ca',
|
'authorized_phone_country' => 'fr,be,ca',
|
||||||
'mms' => 0,
|
'mms' => 1,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Vous avez reçu un nouveau SMS :
|
Vous avez reçu un nouveau <?= $mms ? 'MMS' : 'SMS'; ?> :
|
||||||
Date : <?= $at ?>
|
Date : <?= $at ?>
|
||||||
|
|
||||||
Origine : <?= $origin ?>
|
Origine : <?= $origin ?>
|
||||||
|
|
Loading…
Reference in New Issue