Implement email_tunnel service and installation scripts for Proton Bridge integration
This commit is contained in:
parent
c10b9e634d
commit
28a1fbe59a
5 changed files with 496 additions and 2 deletions
|
|
@ -206,7 +206,12 @@ def save_last_uid(state_file: str, uid: int) -> None:
|
|||
def connect_imap(config: Config) -> imaplib.IMAP4:
|
||||
# Proton Bridge usually uses STARTTLS on 1143. If you configured SSL-only, switch to IMAP4_SSL.
|
||||
logger.info("Connecting to IMAP %s:%s ...", config.imap_host, config.imap_port)
|
||||
imap = imaplib.IMAP4(config.imap_host, config.imap_port)
|
||||
try:
|
||||
imap = imaplib.IMAP4(config.imap_host, config.imap_port)
|
||||
except (ConnectionRefusedError, OSError) as exc:
|
||||
raise FatalConfigError(
|
||||
f"IMAP connect failed to {config.imap_host}:{config.imap_port}: {exc}"
|
||||
) from exc
|
||||
|
||||
# Upgrade to TLS (verification can be disabled for local Proton Bridge).
|
||||
ssl_context = ssl.create_default_context()
|
||||
|
|
@ -216,7 +221,10 @@ def connect_imap(config: Config) -> imaplib.IMAP4:
|
|||
imap.starttls(ssl_context=ssl_context)
|
||||
|
||||
logger.info("Logging in to IMAP ...")
|
||||
imap.login(config.imap_user, config.imap_password)
|
||||
try:
|
||||
imap.login(config.imap_user, config.imap_password)
|
||||
except imaplib.IMAP4.error as exc:
|
||||
raise FatalConfigError(f"IMAP login failed: {exc}") from exc
|
||||
|
||||
logger.debug("Listing available IMAP folders...")
|
||||
typ, folders = imap.list()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue