Some more fixes in the mail worker

This commit is contained in:
Pinga 2025-02-06 17:08:06 +02:00
parent d931849e1c
commit 6651e3d613

View file

@ -94,6 +94,7 @@ Swoole\Coroutine\run(function() use ($c, $logger, $maxRetries, $retryQueueKey) {
if ($c['mailer'] === 'phpmailer') { if ($c['mailer'] === 'phpmailer') {
$mail = new PHPMailer(true); $mail = new PHPMailer(true);
try { try {
$mail->SMTPDebug = 0;
$mail->isSMTP(); $mail->isSMTP();
$mail->Host = $c['mailer_smtp_host']; $mail->Host = $c['mailer_smtp_host'];
$mail->SMTPAuth = true; $mail->SMTPAuth = true;
@ -101,6 +102,7 @@ Swoole\Coroutine\run(function() use ($c, $logger, $maxRetries, $retryQueueKey) {
$mail->Password = $c['mailer_smtp_password']; $mail->Password = $c['mailer_smtp_password'];
$mail->SMTPSecure = 'tls'; $mail->SMTPSecure = 'tls';
$mail->Port = $c['mailer_smtp_port']; $mail->Port = $c['mailer_smtp_port'];
$mail->setFrom($c['mailer_from']); $mail->setFrom($c['mailer_from']);
$mail->addAddress($data['toEmail']); $mail->addAddress($data['toEmail']);
$mail->Subject = $data['subject']; $mail->Subject = $data['subject'];
@ -109,7 +111,14 @@ Swoole\Coroutine\run(function() use ($c, $logger, $maxRetries, $retryQueueKey) {
$mail->isHTML(true); $mail->isHTML(true);
$mail->AltBody = strip_tags($data['body']); $mail->AltBody = strip_tags($data['body']);
} }
Swoole\Coroutine::create(function() use ($mail) {
try {
$mail->send(); $mail->send();
} catch (Exception $e) {
echo "Mail Error: " . $e->getMessage();
}
});
} catch (PHPMailerException $e) { } catch (PHPMailerException $e) {
$logger->error("PHPMailer error: ", ['error' => $e->getMessage()]); $logger->error("PHPMailer error: ", ['error' => $e->getMessage()]);
} }