+

Add interactive authentication password input feature

Benjamin Renard [2015-11-30 17:47:55]
Add interactive authentication password input feature
Filename
imapt
popt
smtpt
diff --git a/imapt b/imapt
index efef1bc..7824983 100755
--- a/imapt
+++ b/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
diff --git a/popt b/popt
index b9316f4..76328c0 100755
--- a/popt
+++ b/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
diff --git a/smtpt b/smtpt
index e1745c1..9e89e3f 100755
--- a/smtpt
+++ b/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:
ViewGit