pytest-dev / pytest-localserver

py.test plugin to test server connections locally. This repository was migrated from Bitbucket.
MIT License
28 stars 12 forks source link

Feature request: IMAP server #52

Open kvdb opened 2 years ago

kvdb commented 2 years ago

I've been a happy pytest-localserver for a while now. It works great for SMTP. Since we moved from GSuite to self-hosted email, it became clear to me that sent emails are no longer automatically appearing in the Sent folder. So I now had add code to connect to the IMAP server and append the message to the Sent folder. It'd be useful if pytest-localserver would also provide support for IMAP.

diazona commented 2 years ago

Hi @kvdb, thanks for your message!

In principle I'd be totally happy to add IMAP support (and I'm sure @redtoad would agree). We would need a Python implementation of an IMAP server; after a quick search I found https://github.com/scanner/asimap (but I can't tell if that's installable through pip) and https://pypi.org/project/localmail/ (but that may not be maintained anymore, and is also GPLv3 which would be incompatible with this project's own license). If you (or anyone) can suggest a better option for an IMAP server, that would be great.

Also, if you haven't seen it, I'd suggest reviewing the discussion about whether pytest-localserver should be retired. The unfortunate truth is that this package's support for SMTP is pretty shaky, since both Python's own smtpd module and the aiosmtpd package which was supposed to replace it are basically unmaintained and may not have much life left in them; and without SMTP, pytest-localserver is little more than a simpler version of pytest-httpserver. In general, things seem to be moving in the direction of having separate packages for testing different protocols, rather than pytest-localserver's approach which is one package that handles multiple server protocols; the separate protocol-specific packages are much more actively developed. So we'd have to take that into account when deciding whether to add IMAP support here. If we don't, it could always be a separate package.

diazona commented 8 months ago

Just wanted to reaffirm that the blocker to this is finding a suitable IMAP server library which is stable, maintained, and installable from PyPI. If we find a library meeting those criteria, I'm happy to implement this, but honestly, unless somebody can suggest one it's unlikely that this improvement is going to happen. I'll leave the issue open just in case, but if it doesn't get any further activity, that's why.