mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-12-01 04:40:45 +09:00
Fix massmailer's send functionality (#1688)
This commit is contained in:
1 parent
cf1093c9ca
commit
ed73d8a14a
1 file changed
+21
-14
@@ -161,33 +161,40 @@ class Service implements \FOSSBilling\InjectionAwareInterface
|
||||
throw new \Box_Exception('Disabled for security reasons (Demo mode enabled)');
|
||||
}
|
||||
|
||||
$mail = $this->di['mail'];
|
||||
$mail->setSubject($data['subject']);
|
||||
$mail->setBodyHtml($data['content']);
|
||||
$mail->setFrom($data['from'], $data['from_name']);
|
||||
$mail->addTo($data['to'], $data['to_name']);
|
||||
|
||||
if (!Environment::isProduction()) {
|
||||
if ($this->di['config']['debug']) {
|
||||
error_log('Skip email sending. Application ENV: ' . Environment::getCurrentEnvironment());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$mod = $this->di['mod']('email');
|
||||
$settings = $mod->getConfig();
|
||||
// Setup the email settings & recipients
|
||||
$settings = $this->di['mod']('email')->getConfig();
|
||||
$transport = $settings['mailer'] ?? 'sendmail';
|
||||
$customDSN = $settings['custom_dsn'] ?? null;
|
||||
$sender = [
|
||||
'email' => $data['from'],
|
||||
'name' => $data['from_name'],
|
||||
];
|
||||
$recipient = [
|
||||
'email' => $data['to'],
|
||||
'name' => $data['to_name'],
|
||||
];
|
||||
|
||||
try {
|
||||
// Send the email
|
||||
$mail = new \FOSSBilling\Mail($sender, $recipient, $data['subject'], $data['content'], $transport, $customDSN);
|
||||
$mail->send($settings);
|
||||
} catch (\Exception $e) {
|
||||
error_log($e->getMessage());
|
||||
}
|
||||
|
||||
// Log the email activity to the database if enabled
|
||||
if (isset($settings['log_enabled']) && $settings['log_enabled']) {
|
||||
$activityService = $this->di['mod_service']('activity');
|
||||
$activityService->logEmail($data['subject'], $client_id, $data['from'], $data['to'], $data['content']);
|
||||
}
|
||||
|
||||
$emailSettings = $this->di['mod_config']('email');
|
||||
$transport = $data['mailer'] ?? 'sendmail';
|
||||
|
||||
$mail->send($transport, $emailSettings);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user