mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2024-11-22 02:17:26 +00:00
mail test: catch typical connecting errors and display nicer output
This commit is contained in:
parent
fff06f7d71
commit
d6e6cfd3c9
@ -12,8 +12,18 @@ host, emailaddress, pw = sys.argv[1:4]
|
|||||||
|
|
||||||
# Attempt to login with IMAP. Our setup uses email addresses
|
# Attempt to login with IMAP. Our setup uses email addresses
|
||||||
# as IMAP/SMTP usernames.
|
# as IMAP/SMTP usernames.
|
||||||
|
try:
|
||||||
M = imaplib.IMAP4_SSL(host)
|
M = imaplib.IMAP4_SSL(host)
|
||||||
M.login(emailaddress, pw)
|
M.login(emailaddress, pw)
|
||||||
|
except OSError as e:
|
||||||
|
print("Connection error:", e)
|
||||||
|
sys.exit(1)
|
||||||
|
except imaplib.IMAP4.error as e:
|
||||||
|
# any sort of login error
|
||||||
|
e = ", ".join(a.decode("utf8") for a in e.args)
|
||||||
|
print("IMAP error:", e)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
M.select()
|
M.select()
|
||||||
print("IMAP login is OK.")
|
print("IMAP login is OK.")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user