Ask for SMTP password if it's not provided
authorPavel Roskin <proski@gnu.org>
Mon, 20 Aug 2007 21:36:00 +0000 (22:36 +0100)
committerCatalin Marinas <catalin.marinas@gmail.com>
Mon, 20 Aug 2007 21:36:33 +0000 (22:36 +0100)
Mention this in examples/gitconfig, explain SMTP options in more detail.

Signed-off-by: Pavel Roskin <proski@gnu.org>
examples/gitconfig
stgit/commands/mail.py

index 3abbe6a..e402208 100644 (file)
        # 'refresh' will automatically mark the conflicts as resolved
        #autoresolved = no
 
+       # SMTP server for sending patches
        #smtpserver = localhost:25
+
+       # Set to 'yes' to use SMTP over TLS
+       #smtptls = no
+
+       # Username for SMTP authentication, required if TLS is used
        #smtpuser = username
+
+       # Password for SMTP.  If not provided, it will be asked
        #smtppassword = password
-       #smtptls = no
 
        # delay between messages in seconds (defaults to 5)
        #smtpdelay = 5
index 7ed5c27..69712cb 100644 (file)
@@ -15,7 +15,7 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 """
 
-import sys, os, re, time, datetime, socket, smtplib
+import sys, os, re, time, datetime, socket, smtplib, getpass
 import email, email.Utils, email.Header
 from optparse import OptionParser, make_option
 
@@ -492,10 +492,10 @@ def func(parser, options, args):
 
     if (smtppassword and not smtpuser):
         raise CmdException, 'SMTP password supplied, username needed'
-    if (smtpuser and not smtppassword):
-        raise CmdException, 'SMTP username supplied, password needed'
     if (smtpusetls and not smtpuser):
         raise CmdException, 'SMTP over TLS requested, username needed'
+    if (smtpuser and not smtppassword):
+        smtppassword = getpass.getpass("Please enter SMTP password: ")
 
     total_nr = len(patches)
     if total_nr == 0: