mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2024-12-22 07:17:05 +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
|
||||
# as IMAP/SMTP usernames.
|
||||
M = imaplib.IMAP4_SSL(host)
|
||||
M.login(emailaddress, pw)
|
||||
try:
|
||||
M = imaplib.IMAP4_SSL(host)
|
||||
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()
|
||||
print("IMAP login is OK.")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user