Roundup, smtplib, TLS and MS Exchange

carlistixx carlistixx at gmail.com
Sun Jun 3 20:55:18 EDT 2007


Thanks for your response. I tried modifying the Roundup code as suggested:

class SMTPConnection(smtplib.SMTP):
    ''' Open an SMTP connection to the mailhost specified in the config
    '''
    def __init__(self, config):

        smtplib.SMTP.__init__(self, config.MAILHOST)
        self.set_debuglevel(1)
        # start the TLS if requested
        if config["MAIL_TLS"]:
            self.ehlo()
            self.starttls(config["MAIL_TLS_KEYFILE"],
                config["MAIL_TLS_CERTFILE"])
            self.ehlo()

        # ok, now do we also need to log in?
        mailuser = config["MAIL_USERNAME"]
        if mailuser:
            self.login(mailuser, config["MAIL_PASSWORD"])

I've inserted a call to ehlo() before and after the call to
starttls(). Adding the first call to ehlo() does help - I don't get so
many complaints from the server. But it still doesn't work- it seems
like the server stops responding after the call to starttls().

I have not specified a keyfile or certfile in the Roundup
configuration, but as I understand it these are optional, so I presume
this is not causing the problem.

[foobar at moe tracker]$ roundup-server -p 8081
roundup=/home/foobar/roundup/tracker
Roundup server started on :8081
send: 'ehlo moe.foobar.local\r\n'
reply: '250-smtpx15.msoutlookonline.net Hello [202.173.131.223]\r\n'
reply: '250-SIZE 31457280\r\n'
reply: '250-PIPELINING\r\n'
reply: '250-ENHANCEDSTATUSCODES\r\n'
reply: '250-STARTTLS\r\n'
reply: '250-AUTH LOGIN\r\n'
reply: '250-8BITMIME\r\n'
reply: '250-BINARYMIME\r\n'
reply: '250 CHUNKING\r\n'
reply: retcode (250); Msg: smtpx15.msoutlookonline.net Hello [202.173.131.223]
SIZE 31457280
PIPELINING
ENHANCEDSTATUSCODES
STARTTLS
AUTH LOGIN
8BITMIME
BINARYMIME
CHUNKING
send: 'STARTTLS\r\n'
reply: '220 2.0.0 SMTP server ready\r\n'
reply: retcode (220); Msg: 2.0.0 SMTP server ready
send: 'ehlo moe.foobar.local\r\n'
send: 'ehlo moe.foobar.local\r\n'
reply: '250-smtpx15.msoutlookonline.net Hello [202.173.131.223]\r\n'
reply: '250-SIZE 31457280\r\n'
reply: '250-PIPELINING\r\n'
reply: '250-ENHANCEDSTATUSCODES\r\n'
reply: '250-STARTTLS\r\n'
reply: '250-AUTH LOGIN\r\n'
reply: '250-8BITMIME\r\n'
reply: '250-BINARYMIME\r\n'
reply: '250 CHUNKING\r\n'
reply: retcode (250); Msg: smtpx15.msoutlookonline.net Hello [202.173.131.223]
SIZE 31457280
PIPELINING
ENHANCEDSTATUSCODES
STARTTLS
AUTH LOGIN
8BITMIME
BINARYMIME
CHUNKING
send: 'STARTTLS\r\n'
reply: '220 2.0.0 SMTP server ready\r\n'
reply: retcode (220); Msg: 2.0.0 SMTP server ready
send: 'ehlo moe.foobar.local\r\n'
192.168.100.68 - - [04/Jun/2007 10:43:24] "POST /roundup/issue1638
HTTP/1.1" 400 -
EXCEPTION AT Mon Jun  4 10:43:24 2007
Traceback (most recent call last):
  File "/usr/lib/python2.3/site-packages/roundup/scripts/roundup_server.py",
line 106, in run_cgi
    self.inner_run_cgi()
  File "/usr/lib/python2.3/site-packages/roundup/scripts/roundup_server.py",
line 266, in inner_run_cgi
    tracker.Client(tracker, self, env).main()
  File "/usr/lib/python2.3/site-packages/roundup/cgi/client.py", line
196, in main
    self.inner_main()
  File "/usr/lib/python2.3/site-packages/roundup/cgi/client.py", line
314, in inner_main
    self.mailer.exception_message()
  File "/usr/lib/python2.3/site-packages/roundup/mailer.py", line 153,
in exception_message
    self.standard_message(to, subject, content)
  File "/usr/lib/python2.3/site-packages/roundup/mailer.py", line 93,
in standard_message
    self.smtp_send(to, message)
  File "/usr/lib/python2.3/site-packages/roundup/mailer.py", line 173,
in smtp_send
    smtp = SMTPConnection(self.config)
  File "/usr/lib/python2.3/site-packages/roundup/mailer.py", line 194,
in __init__
    self.ehlo()
  File "/usr/lib/python2.3/smtplib.py", line 390, in ehlo
    (code,msg)=self.getreply()
  File "/usr/lib/python2.3/smtplib.py", line 344, in getreply
    line = self.file.readline()
  File "/usr/lib/python2.3/smtplib.py", line 159, in readline
    chr = self.sslobj.read(1)
sslerror: The read operation timed out





On 6/1/07, Tijs <tijs_news at bluescraper.nl> wrote:
> carlistixx wrote:
>
> > [foobar at moe tracker]$ roundup-server -p 8081
> > roundup=/home/foobar/roundup/tracker
> > Roundup server started on :8081
> > send: 'STARTTLS\r\n'
> > reply: '503 5.5.2 Send hello first\r\n'
> > reply: retcode (503); Msg: 5.5.2 Send hello first
>
> I think this must be an issue with roundup, issuing commands in the wrong
> order. The correct order should (according to the rfc and the python docs)
> be:
> * ehlo()
> * starttls()
> * ehlo()
> * login()
> ...
>
> --
>
> Regards,
> Tijs
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list