Comment 1 for bug 76239

Revision history for this message
John A Meinel (jameinel) wrote :

Can you include the traceback from ~/.bzr.log? I realize it may be hard to reproduce now.

But I'm trying to figure out which line is failing. We specifically do:

smtp = smtplib.SMTP()
smtp.connect(server)

try:
    # The world can always use a little bit more encryption :)
    smtp.starttls()
except smtplib.SMTPException:
    pass

if smtp_username is not None:
    if smtp_password is None:
        smtp_password = bzrlib.ui.ui_factory.get_password(
            'Please enter SMTP password for %(host)s', host=server)
    try:
        smtp.login(smtp_username, smtp_password)
    except smtplib.SMTPHeloError, e:
        raise BzrCommandError('SMTP server refused HELO: %d %s'
                              % (e.smtp_code, e.smtp_error))
    except smtplib.SMTPAuthenticationError, e:
        raise BzrCommandError('SMTP server refused authentication: %d %s'
                              % (e.smtp_code, e.smtp_error))
    except smtplib.SMTPException, e:
        raise BzrCommandError(str(e))

Which looks like we should be doing the right thing. It would seem that 'connect()' should be failing.

I suppose it is possible that we are running into the final

    except smtplib.SMTPException, e:
        raise BzrCommandError(str(e))

Which means that we need to trap another specific exception at this point.

I can see this happening:
>>> s.connect('mynonexistantserver.com')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.4/smtplib.py", line 292, in connect
    for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
socket.gaierror: (-2, 'Name or service not known')

But that is if the domain doesn't resolve.

If I stop the local mail server I get:
>>> s.connect('localhost')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.4/smtplib.py", line 306, in connect
    raise socket.error, msg
socket.error: (111, 'Connection refused')

Which again seems reasonable.

Can you reproduce this?