Add interactive authentication password input feature
This commit is contained in:
parent
f9d216e372
commit
a2ccabb9e8
3 changed files with 15 additions and 4 deletions
8
imapt
8
imapt
|
@ -31,6 +31,7 @@ import logging
|
|||
import sys
|
||||
|
||||
import re
|
||||
import getpass
|
||||
|
||||
parser = OptionParser()
|
||||
|
||||
|
@ -123,10 +124,13 @@ else:
|
|||
|
||||
logging.basicConfig(level=loglevel,format='%(asctime)s - %(levelname)s - %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p')
|
||||
|
||||
if not options.user or not options.password:
|
||||
logging.fatal('You must provide the user login and password')
|
||||
if not options.user:
|
||||
logging.fatal('You must provide the user login')
|
||||
sys.exit(1)
|
||||
|
||||
if not options.password:
|
||||
options.password=getpass.getpass()
|
||||
|
||||
if options.port is None:
|
||||
if options.ssl:
|
||||
options.port=993
|
||||
|
|
8
popt
8
popt
|
@ -26,6 +26,7 @@ from optparse import OptionParser
|
|||
|
||||
import os
|
||||
import poplib
|
||||
import getpass
|
||||
|
||||
import logging
|
||||
import sys
|
||||
|
@ -91,10 +92,13 @@ else:
|
|||
|
||||
logging.basicConfig(level=loglevel,format='%(asctime)s - %(levelname)s - %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p')
|
||||
|
||||
if not options.user or not options.password:
|
||||
logging.fatal('You must provide the user login and password')
|
||||
if not options.user:
|
||||
logging.fatal('You must provide the user login')
|
||||
sys.exit(1)
|
||||
|
||||
if not options.password:
|
||||
options.password=getpass.getpass()
|
||||
|
||||
if options.port is None:
|
||||
if options.ssl:
|
||||
options.port=995
|
||||
|
|
3
smtpt
3
smtpt
|
@ -31,6 +31,7 @@ from email.MIMEText import MIMEText
|
|||
from email.MIMEMultipart import MIMEMultipart
|
||||
from email.MIMEBase import MIMEBase
|
||||
from email import Encoders
|
||||
import getpass
|
||||
|
||||
import logging
|
||||
import sys
|
||||
|
@ -234,6 +235,8 @@ if options.debug:
|
|||
|
||||
if options.user:
|
||||
error = None
|
||||
if not options.password:
|
||||
options.password=getpass.getpass()
|
||||
try:
|
||||
server.login(options.user,options.password)
|
||||
except Exception as e:
|
||||
|
|
Loading…
Reference in a new issue