Skip to content

fix(mail): keep master SMTP credentials for CLI without session password - #219

Open
TDannhauer wants to merge 1 commit into
FRAMEWORK_6_0from
fix/mail-cli-smtp-credentials
Open

fix(mail): keep master SMTP credentials for CLI without session password#219
TDannhauer wants to merge 1 commit into
FRAMEWORK_6_0from
fix/mail-cli-smtp-credentials

Conversation

@TDannhauer

Copy link
Copy Markdown
Contributor

Summary

  • Keep configured master SMTP username/password when CLI/user_admin has an auth name but no session password
  • Prevents horde-alarms from authenticating to SMTP with an empty password under username_auth/password_auth
  • Add unit coverage for CLI fallback and normal session credential overlay

Motivation

horde-alarms initializes Horde with user_admin, which sets an admin identity without credentials. With mailer username_auth/password_auth enabled, Horde_Core_Factory_Mail::getConfig() overwrote the configured master SMTP credentials with that admin username and getAuthCredential('password') (empty/false). SMTP then returned Server denied authentication. Because failed alarm mails never set internal['mail']['sent'], the same alarm was retried on every cron run until a web session with real credentials sent it successfully — producing intermittent multi-hour error bursts.

Changes

  • Apply session SMTP credentials only when a non-empty session password is present
  • When password_auth is enabled but no session password exists, retain master username and password
  • Partial smtp_credentials hook results only overlay the omitted keys
  • New MailFactoryTest covering CLI fallback, session overlay, and empty-password handling

Test plan

  • vendor/bin/phpunit -c vendor/horde/core/phpunit.xml.dist --bootstrap vendor/autoload.php vendor/horde/core/test/Unit/Factory/MailFactoryTest.php
  • Run horde-alarms while a mail alarm is pending; confirm SMTP auth succeeds with master credentials
  • Confirm a normal web session still sends mail using the logged-in user's credentials when *_auth is enabled

horde-alarms runs with user_admin authentication (name only, no password).
With username_auth/password_auth enabled, getConfig() previously overwrote
the configured master SMTP credentials with the admin username and an empty
password, causing intermittent Server denied authentication errors until a
web session successfully sent the alarm mail.

Only apply session credentials when a non-empty session password is present;
otherwise retain the configured master username/password.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants