Repository navigation
Email: easier setup, folders with spaces, and cancelled loads - #7
Open
Thomaspeel6 wants to merge 3 commits into
Open
Thomaspeel6 wants to merge 3 commits into
Thomaspeel6 wants to merge 3 commits into
Conversation
…e saving The Connect Email sheet required IMAP and SMTP hosts and ports, although the backend can already derive them from the address for Gmail, iCloud, Outlook, Fastmail and Yahoo (email_account_from_login, via /api/email/connect, which nothing called). The sheet now asks for the address and an app password, uses that route, and keeps the server fields under "Advanced: mail servers" for other providers. A link to the provider's app-password page appears once the address is recognised. Both connect routes now try the IMAP login before saving and return a readable error. Previously a wrong password or host was saved as connected and only surfaced later as an error in the inbox. A manual setup that does not state the TLS mode now infers it from the port (143 and 587/25 use STARTTLS). Defaulting both to implicit TLS meant a mailbox set up with SMTP port 587 could not send. Adds the first email tests, run against a local fake IMAP server.
imaplib sends mailbox names verbatim, so a name containing a space reached the
server as two arguments. Every Gmail system folder except INBOX ("[Gmail]/Sent
Mail", "[Gmail]/All Mail") and any user folder with a space failed with
"EXAMINE command error: BAD Could not parse command".
Names are now sent as IMAP quoted strings wherever a folder is selected.
The inbox load runs in a .task keyed on folder and filter, so it is cancelled when the tab is switched away or the folder changes. The catch block showed that as "Couldn't load — cancelled", even over a working mailbox. A cancelled load is now ignored; the next load replaces it.
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.
Three email changes found while connecting a Gmail account, one commit each. Part of the email setup proposal in #8.
1. Setup asks for address and app password only, and signs in before saving
Why: Connecting a mailbox currently means knowing your provider's IMAP and SMTP hosts and ports, and the Connect button stays disabled until all four are typed in. The backend can already work them out from the address for Gmail, iCloud, Outlook, Fastmail and Yahoo (
email_account_from_login, behind/api/email/connect), but nothing called that route.SettingsView.swift,APIClient.swift): address and app password use/api/email/connect. The four server fields move under "Advanced: mail servers" and still go through/api/email/connect-imap. A "How to create a … app password" link appears for Gmail, iCloud, Yahoo and Fastmail addresses.jb_email.py,joebro_backend.py): both connect routes try the IMAP login first and return a readable error. Before, a wrong password or host was saved as connected and only showed up later as an error in the inbox.2. Folders with a space in the name fail to open
Selecting any Gmail folder other than Inbox ("[Gmail]/Sent Mail", "[Gmail]/All Mail"), or any user folder with a space in its name, shows:
imaplibsends mailbox names verbatim, so a name with a space reaches the server as two arguments. A smallimap_mailbox()helper now sends the name as an IMAP quoted string, in the four places a folder is selected.3. A cancelled load is shown as "Couldn't load — cancelled"
The inbox load runs in a
.taskkeyed on folder and filter, so SwiftUI cancels it when the tab or folder changes, and thecatchreported that as a failure over a working mailbox. A cancelled load is now ignored; the next one replaces it (EmailPanel.swift).Behaviour changes to be aware of
_bridge_types()) skip the login check, as before.Tested
test_email.pyandtest_email_folders.py, run against a local fake IMAP server. Email had none. The full backend suite passes (92 tests) on the macOS system Python./api/email/list.If you'd rather review these separately, the three commits split cleanly.