moralmunky / Home-Assistant-Mail-And-Packages

Home Assistant integration providing day of package counts and USPS informed delivery images.
MIT License
644 stars 82 forks source link

ISSUE: iCloud IMAP server not supported #1005

Open rscheuermann opened 1 week ago

rscheuermann commented 1 week ago

Describe the bug Using iCloud's IMAP server (imap.mail.me.com) will never find and process emails because IMAP's server does not support RFC822 fetch protocol.

The solution is to switch to BODY[]. I've done this in my local helpers.py and it works!

See: https://stackoverflow.com/questions/75444763/python-imaplib-fetching-icloud-mail-rfc822-not-working

I'll open a PR to fix as soon as I'm able.

Environment (please complete the following information):

Logs When using iCloud, the FETCH result will always look like this:

2024-11-18 10:36:51.087 DEBUG (SyncWorker_9) [custom_components.mail_and_packages.helpers] email_search value: ('OK', [b'1'])

Screenshots N/A

Additional context The fix may require introducing a new configuration variable to switch from RFC822 to BODY[] fetch parameters. Switching the core code to BODY[] for all mail servers may break backwards compatibility.

github-actions[bot] commented 3 days ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

ID-Ant commented 2 days ago

hi @rscheuermann - would you mind post more detail on how you resolved this please?

firstof9 commented 2 days ago

Anywhere email_fetch is called the (RFC822) will need to be adjusted in the call.

Plan is to modify the function to check if you're using iCloud's monstrosity of an IMAP server, and adjust the call accordingly in a single spot.