[TikiWiki-commits] [Git][tikiwiki/tiki][24.x] [BP][FIX] Failed sending mail with no recipients
"ushindi bienvenu \(@usbbush\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <68a7c98b64702_2cd6de4534d1@gitlab-sidekiq-low-urgency-cpu-bound-v2-5f6d84f9cc-b7vzw.mail> |
ushindi bienvenu pushed to branch 24.x at Tiki Wiki CMS Groupware / Tiki
Commits:
f511f5fc by ushindi bienvenu at 2025-08-22T01:30:13+00:00
[BP][FIX] Failed sending mail with no recipients
---
* [BP][FIX] Failed sending mail with no recipients
---
* [BP][FIX] Failed sending mail with no recipients
---
* [FIX] Failed sending mail with no recipients
---
* [FIX] Failed sending mail with no recipients
---
* [FIX] Failed sending mail with no recipients
See merge request tikiwiki/tiki!8316
See merge request tikiwiki/tiki!8354
See merge request tikiwiki/tiki!8360
See merge request tikiwiki/tiki!8362
See merge request tikiwiki/tiki!8363
- - - - -
1 changed file:
- lib/core/Tiki/Command/MailQueueSendCommand.php
Changes:
=====================================
lib/core/Tiki/Command/MailQueueSendCommand.php
=====================================
@@ -42,32 +42,36 @@ class MailQueueSendCommand extends Command
$error = '';
if ($mail && (get_class($mail) === 'Laminas\Mail\Message' || get_class($mail) === 'Zend\Mail\Message')) {
- try {
- tiki_send_email($mail);
- $title = 'mail';
- } catch (ZendMailException | SlmMailException $e) {
- $title = 'mail error';
- $error = $e->getMessage();
- }
-
- if ($error || $prefs['log_mail'] == 'y') {
- foreach ($mail->getTo() as $destination) {
- $logslib->add_log($title, $error . "\n " . $destination->getEmail() . '/' . $mail->getSubject());
- }
- foreach ($mail->getCc() as $destination) {
- $logslib->add_log($title, $error . "\n " . $destination->getEmail() . '/' . $mail->getSubject());
+ $query = 'DELETE FROM tiki_mail_queue WHERE messageId = ?';
+ if (empty($this->collectRecipients($mail))) {
+ $output->writeln('Deleted object id: ' . $message['messageId'] . ' (mail has no recipients)');
+ } else {
+ try {
+ tiki_send_email($mail);
+ $title = 'mail';
+ } catch (ZendMailException | SlmMailException $e) {
+ $title = 'mail error';
+ $error = $e->getMessage();
}
- foreach ($mail->getBcc() as $destination) {
- $logslib->add_log($title, $error . "\n " . $destination->getEmail() . '/' . $mail->getSubject());
+
+ if ($error || $prefs['log_mail'] == 'y') {
+ foreach ($mail->getTo() as $destination) {
+ $logslib->add_log($title, $error . "\n " . $destination->getEmail() . '/' . $mail->getSubject());
+ }
+ foreach ($mail->getCc() as $destination) {
+ $logslib->add_log($title, $error . "\n " . $destination->getEmail() . '/' . $mail->getSubject());
+ }
+ foreach ($mail->getBcc() as $destination) {
+ $logslib->add_log($title, $error . "\n " . $destination->getEmail() . '/' . $mail->getSubject());
+ }
}
- }
- if ($error) {
- $query = 'UPDATE tiki_mail_queue SET attempts = attempts + 1 WHERE messageId = ?';
- $output->writeln('Failed sending mail object id: ' . $message['messageId'] . ' (' . $error . ')');
- } else {
- $query = 'DELETE FROM tiki_mail_queue WHERE messageId = ?';
- $output->writeln('Sent.');
+ if ($error) {
+ $query = 'UPDATE tiki_mail_queue SET attempts = attempts + 1 WHERE messageId = ?';
+ $output->writeln('Failed sending mail object id: ' . $message['messageId'] . ' (' . $error . ')');
+ } else {
+ $output->writeln('Sent.');
+ }
}
\TikiDb::get()->query($query, [$message['messageId']]);
@@ -77,4 +81,19 @@ class MailQueueSendCommand extends Command
}
$output->writeln('Mail queue processed...');
}
+
+ private function collectRecipients($mail)
+ {
+ $recipients = [];
+ foreach ($mail->getTo() as $destination) {
+ $recipients[] = $destination->getEmail();
+ }
+ foreach ($mail->getCc() as $destination) {
+ $recipients[] = $destination->getEmail();
+ }
+ foreach ($mail->getBcc() as $destination) {
+ $recipients[] = $destination->getEmail();
+ }
+ return $recipients;
+ }
}
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/f511f5fc24303f9488ce8990f04ec5fb2c944d66
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/f511f5fc24303f9488ce8990f04ec5fb2c944d66
You're receiving this email because of your account on gitlab.com.
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs