Skip to content

Add SMTP authentication support for globally configured relay servers#3555

Open
adepretis wants to merge 2 commits intopostalserver:mainfrom
dogado-group:main
Open

Add SMTP authentication support for globally configured relay servers#3555
adepretis wants to merge 2 commits intopostalserver:mainfrom
dogado-group:main

Conversation

@adepretis
Copy link
Copy Markdown

Summary

This change adds SMTP authentication support for globally configured relay servers in postal.smtp_relays.

Postal already supports relay entries like:

postal:
  smtp_relays:
    - smtp://hostname:port?ssl_mode=...

With this change, relay URLs can also include SMTP credentials:

postal:
  smtp_relays:
    - smtp://username:password@hostname:port?ssl_mode=...

When credentials are present, Postal connects to the relay using SMTP LOGIN authentication. When they are not present, behavior remains unchanged.

What changed

  • Extended relay URL parsing in lib/postal/config_schema.rb to extract:
    • username
    • password
  • Extended SMTPClient::Server to carry optional relay credentials.
  • Updated relay construction in SMTPSender.smtp_relays to pass parsed credentials through to the SMTP client layer.
  • Updated SMTPClient::Endpoint#start_smtp_session to call:
    • start(helo_hostname, username, password, :login) when credentials are configured
    • start(helo_hostname) otherwise
  • Updated configuration documentation to mention the authenticated relay URL format.
  • Added test coverage for:
    • unauthenticated relay URLs
    • authenticated relay URLs
    • percent-encoded credentials
    • authenticated relay propagation through SMTPSender
    • authenticated SMTP session startup

Backward compatibility

This is fully backward compatible for existing installations using unauthenticated relay URLs.

Notes

  • This change is intentionally limited to postal.smtp_relays.
  • It does not add authentication support to DB-backed SMTPEndpoint records or the UI.
  • Authentication type is fixed to SMTP LOGIN for now.

@adepretis
Copy link
Copy Markdown
Author

@adamcooke any comment?

@adepretis
Copy link
Copy Markdown
Author

Anyone? - @willpower232 maybe?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants