Skip to content

Commit

Permalink
Merge pull request #8 from CPS-IT/feature/recoverable-transport
Browse files Browse the repository at this point in the history
[FEATURE] Introduce recoverable transports
  • Loading branch information
eliashaeussler committed Mar 6, 2024
2 parents 76d4ac9 + ac0b768 commit 0a83455
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Classes/Mail/Transport/QueueableFileTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* @author Elias Häußler <e.haeussler@familie-redlich.de>
* @license GPL-2.0-or-later
*/
final class QueueableFileTransport extends Core\Mail\FileSpool implements QueueableTransport
final class QueueableFileTransport extends Core\Mail\FileSpool implements RecoverableTransport
{
public const FILE_SUFFIX_QUEUED = '.message';
public const FILE_SUFFIX_SENDING = '.message.sending';
Expand Down
35 changes: 35 additions & 0 deletions Classes/Mail/Transport/RecoverableTransport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

/*
* This file is part of the TYPO3 CMS extension "mailqueue".
*
* Copyright (C) 2024 Elias Häußler <e.haeussler@familie-redlich.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

namespace CPSIT\Typo3Mailqueue\Mail\Transport;

/**
* RecoverableTransport
*
* @author Elias Häußler <e.haeussler@familie-redlich.de>
* @license GPL-2.0-or-later
*/
interface RecoverableTransport extends QueueableTransport
{
public function recover(int $timeout = 900): void;
}
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,19 @@ methods to enqueue and dequeue mails:
with the difference that it only dequeues the given mail queue item and leaves the
rest of the queue untouched.

#### Recoverable transports

Next to the `QueueableTransport` interface there exists an extended interface
[`CPSIT\Typo3Mailqueue\Mail\Transport\RecoverableTransport`](Classes/Mail/Transport/RecoverableTransport.php).
It allows to recover stuck mails with a configured recover timeout:

* ```php
public function recover(int $timeout = 900): void
```
Recovers mails that are enqueued for longer than the given timeout (in seconds) and
are in "sending" state. Recovering a mail resets their mail state from "sending" to
"queued". They will then be sent again on dequeue or when the mail queue is flushed.

### Backend module

> [!NOTE]
Expand Down

0 comments on commit 0a83455

Please sign in to comment.