Files
projectsend/app/Modules/Platform/Mail/MailOAuthException.php
denkfabrik-li 933eaa2ba4 Send mail through Microsoft Graph as an admin-connected mailbox
Adds "Microsoft 365 (OAuth)" to the Email settings provider dropdown.
Selecting it swaps the SMTP form for an app registration (client id,
secret, optional tenant) and a "Connect mailbox" flow: the admin signs
into the mailbox the installation should send as, and outgoing email
goes through Graph sendMail as that mailbox — no password, no app
password, no SMTP AUTH, which Microsoft is winding down.

Delegated flow on purpose: it needs no admin consent and works for
work/school and personal accounts alike. Its one weakness — a grant
can die silently behind a password reset or a Conditional Access
change — is answered by a daily scheduled refresh that keeps the
token alive and, on a dead grant, warns the settings admins once
in-app and on the settings page instead of letting mail stop quietly.

Tokens and the client secret live encrypted in their own row and are
read fresh at send time, never through the boot-config cache. The
stored SMTP transport survives a provider switch untouched.
2026-08-23 22:46:24 +02:00

27 lines
710 B
PHP

<?php
declare(strict_types=1);
namespace App\Modules\Platform\Mail;
use RuntimeException;
/**
* A failed token exchange or refresh.
*
* `needsReconnect` separates the two situations an admin can be in: the
* grant itself is dead (revoked consent, password/Conditional-Access
* change, expired refresh token — only re-running the connect flow
* helps) versus a transient failure (endpoint unreachable, 5xx) where
* the existing connection is fine and retrying is the answer.
*/
class MailOAuthException extends RuntimeException
{
public function __construct(
string $message,
public readonly bool $needsReconnect = false,
) {
parent::__construct($message);
}
}