Repository navigation
Per-login ForwardEmail accounts with From check - #1
Merged
Merged
Conversation
Each SMTP login can now map to its own ForwardEmail alias credentials via BRIDGE_ACCOUNTS (a JSON list), so apps sharing the bridge can send as different addresses without a catch-all password. The single-login variables keep working unchanged and can be combined with BRIDGE_ACCOUNTS. - AUTH records the matched account on the session; the message is relayed with that account's credentials. - The From header must be that account's alias (case-insensitive), else a permanent 553 naming the expected address instead of a 451 retry loop. - Passwords are compared in constant time, as bytes. - Bad config (missing/empty/unknown keys, invalid JSON, duplicate SMTP usernames) fails at startup without echoing values. Assisted-by: Claude Code:claude-opus-5-5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Lets each SMTP login map to its own ForwardEmail alias credentials, so apps sharing the bridge can send as different addresses without a domain catch-all password.
Config
New optional
BRIDGE_ACCOUNTS, a JSON list:[{"smtp_username": "glitchtip", "smtp_password": "...", "forwardemail_username": "alerts@example.com", "forwardemail_password": "..."}]SMTP_USERNAME/SMTP_PASSWORD/FORWARDEMAIL_USERNAME/FORWARDEMAIL_PASSWORDkeep working exactly as before. If both are set, the single-login variables become one more account, so the live deployment needs no config change and can add logins later.smtp_pasword), or duplicate SMTP usernames across both sources. Messages name the index and key, never the values.Behavior
hmac.compare_digeston bytes, checked against every account with no early exit) and returns it asauth_data, which aiosmtpd stores on the session. Failures still returnAuthResult(success=False, handled=False).handle_DATArelays with that session's account credentials.ForwardEmailRelayis now one shared client that takes credentials persend.553 From address must be <alias> for this login, a permanent error, instead of ForwardEmail's 403 becoming a 451 that apps retry forever. MAIL FROM (envelope/bounce address) is not checked.Accounthides both passwords fromrepr.Tests
62 passing (was 24). New coverage: legacy config, multi-account config, combined sources, duplicate and malformed config, per-session credential selection over a real socket, From mismatch (wrong address, look-alike domain, two addresses, missing From) as 553, case and display-name matching, cross-account password and unknown user as 535, non-UTF-8 login as 535.