Postfach: Posteingang wird unter jedem Namen gefunden; kein doppeltes „SSL“
- MailboxReader::folder(): „Posteingang“, „Inbox“ oder leer → INBOX (so heißt der Posteingang auf dem IMAP-Server); andere Namen ohne Beachtung der Groß-/Kleinschreibung; unbekannter Ordner → Meldung mit den vorhandenen Ordnern statt „Call to a member function query() on null“. Gilt für Portal-Abruf, vollständigen Abruf und „Postfach prüfen“. - Verschlüsselung: Platzhalter „Standard (SSL)“ statt eines zweiten „SSL“; Hinweis am Ordnerfeld. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3a039e5c50
commit
154b8a434c
3 files changed
+54
-5
No files matched your search
@@ -7,7 +7,9 @@
|
||||
use Carbon\CarbonImmutable;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Throwable;
|
||||
use Webklex\PHPIMAP\Client;
|
||||
use Webklex\PHPIMAP\ClientManager;
|
||||
use Webklex\PHPIMAP\Folder;
|
||||
use Webklex\PHPIMAP\Message;
|
||||
|
||||
/**
|
||||
@@ -70,7 +72,7 @@ public function fetch(array $senders): array
|
||||
'protocol' => 'imap',
|
||||
]);
|
||||
$client->connect();
|
||||
$folder = $client->getFolderByPath($config['folder']);
|
||||
$folder = self::folder($client, $config['folder']);
|
||||
|
||||
$mails = [];
|
||||
foreach ($senders as $sender) {
|
||||
@@ -119,7 +121,7 @@ public function fetchAll(): array
|
||||
'username' => $config['username'], 'password' => $config['password'], 'protocol' => 'imap',
|
||||
]);
|
||||
$client->connect();
|
||||
$messages = $client->getFolderByPath($config['folder'])->query()
|
||||
$messages = self::folder($client, $config['folder'])->query()
|
||||
->whereSince(CarbonImmutable::today()->subDays((int) config('fewo.mailbox.lookback_days', 3)))
|
||||
->leaveUnread()
|
||||
->get();
|
||||
@@ -156,7 +158,7 @@ public function probe(array $config): int
|
||||
'username' => $config['username'], 'password' => $config['password'], 'protocol' => 'imap',
|
||||
]);
|
||||
$client->connect();
|
||||
$count = $client->getFolderByPath($config['folder'])->query()
|
||||
$count = self::folder($client, $config['folder'])->query()
|
||||
->whereSince(CarbonImmutable::today()->subDays((int) config('fewo.mailbox.lookback_days', 3)))
|
||||
->leaveUnread()->setFetchBody(false)->count();
|
||||
$client->disconnect();
|
||||
@@ -167,6 +169,28 @@ public function probe(array $config): int
|
||||
return (int) $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* The folder to read. The inbox is called "INBOX" on the IMAP server, whatever the provider's web mail shows
|
||||
* ("Posteingang", "Inbox"); other names match regardless of case. An unknown name names the existing folders.
|
||||
*
|
||||
* @throws ChannelSyncException
|
||||
*/
|
||||
public static function folder(Client $client, ?string $name): Folder
|
||||
{
|
||||
$name = trim((string) $name);
|
||||
$wanted = $name === '' || in_array(mb_strtolower($name), ['inbox', 'posteingang'], true) ? 'INBOX' : $name;
|
||||
|
||||
$folders = $client->getFolders(false);
|
||||
$folder = $folders->first(fn (Folder $folder): bool => $folder->path === $wanted)
|
||||
?? $folders->first(fn (Folder $folder): bool => mb_strtolower($folder->path) === mb_strtolower($wanted) || mb_strtolower($folder->name) === mb_strtolower($wanted));
|
||||
|
||||
if ($folder === null) {
|
||||
throw new ChannelSyncException('Ordner „'.$name.'“ gibt es in diesem Postfach nicht. Vorhanden: '.$folders->map(fn (Folder $folder): string => $folder->path)->implode(', ').' (der Posteingang heißt „INBOX“).');
|
||||
}
|
||||
|
||||
return $folder;
|
||||
}
|
||||
|
||||
private function toPortalMail(Message $message): PortalMail
|
||||
{
|
||||
$text = $message->getTextBody();
|
||||
|
||||
Reference in new issue
Block a user