feat: support separate SMTP credentials (username + password) for outgoing server#255
feat: support separate SMTP credentials (username + password) for outgoing server#255SaschaOnTour wants to merge 8 commits intoavihaymenahem:mainfrom
Conversation
- Add smtp_username and smtp_password columns (migration v24) - Fix bug where SMTP password was collected but never persisted - Add SMTP Username field when 'Use same credentials as IMAP' is unchecked - buildSmtpConfig uses smtp_username/smtp_password with fallback to IMAP values - Refactor decryptAccountTokens to use ENCRYPTED_FIELDS loop - Add comprehensive test coverage for AddImapAccount (51 tests)
feat: support separate SMTP credentials (username + password)
There was a problem hiding this comment.
Pull request overview
This PR adds support for configuring separate SMTP credentials (username + password) for IMAP accounts, fixing a UI bug where the SMTP password field existed but was never persisted, and updating the DB + config-building logic to handle the new fields with backward-compatible fallbacks.
Changes:
- Add DB columns
smtp_username/smtp_password(migration v24) and plumb them through the DB account layer (insert + decrypt). - Update SMTP config building to prefer SMTP credentials with fallback to IMAP credentials.
- Update the Add IMAP account UI to support SMTP username + “Use same credentials as IMAP”, and add new unit tests across UI/config/DB.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/mocks/entities.mock.ts | Extends mock DbAccount objects with smtp_username/smtp_password. |
| src/services/imap/imapConfigBuilder.ts | Uses SMTP username/password with fallback to IMAP/email. |
| src/services/imap/imapConfigBuilder.test.ts | Adds tests covering separate SMTP credential fallback behavior. |
| src/services/db/migrations.ts | Adds migration v24 to add smtp_username/smtp_password columns. |
| src/services/db/accounts.ts | Extends DbAccount, refactors token decryption loop, and persists/encrypts SMTP password on insert. |
| src/services/db/accounts.test.ts | Adds/updates tests verifying SMTP username/password persistence and decryption. |
| src/components/accounts/AddImapAccount.tsx | Fixes SMTP password persistence, adds SMTP username field, and renames checkbox semantics to “same credentials”. |
| src/components/accounts/AddImapAccount.test.tsx | Adds comprehensive UI tests including new separate SMTP credentials flow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Revert username fallback to || (empty string is not a valid username) - Keep ?? for password fallback (empty string could be intentional) - Skip SMTP password validation for OAuth auth mode (avoids stuck state) - Update buildSmtpConfig docstring to note decryption requirement - Add edge case test: OAuth mode bypasses sameCredentials validation
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Narrow ENCRYPTED_FIELDS key type to specific string fields (removes unsafe cast) - Import ReactNode type instead of using React namespace - Restore crypto.randomUUID in afterEach to prevent test leaks
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Consistent with IMAP password validation. Checks trimmed value but stores the original to preserve intentional whitespace within passwords.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Allow users to configure completely separate credentials (username + password) for outgoing SMTP, independent from incoming IMAP credentials. This also fixes a bug where the SMTP password field was present in the UI but the value was silently discarded on save.
Changes
AddImapAccount.tsxline 387 hadpassword: form.samePassword ? form.password : form.password— both branches returned the IMAP password, so the SMTP password was never persistedsmtp_usernameandsmtp_passwordcolumns to accounts tableaccounts.ts: ExtendedDbAccountinterface,insertImapAccount, anddecryptAccountTokensfor the new fieldsimapConfigBuilder.ts:buildSmtpConfignow usessmtp_username/smtp_passwordwith 3-level fallback to IMAP values for backward compatibilityAddImapAccount.tsx: Renamed checkbox to "Use same credentials as IMAP", added SMTP Username field, fixed save to pass separate credentialsdecryptAccountTokenswith anENCRYPTED_FIELDSloopAddImapAccount.tsx(previously 0 coverage), 5 forimapConfigBuilder, 5 foraccountsDB layerType of Change
Testing
npm run test) — 1619 tests, 134 filesScreenshots
Fixes #253
Closes #254