Search code examples
pythonsmtptwistedbuildbot

Buildbot (from buildbot.net) : iCloud email not working as Status Target


I am setting up buildbot to use an iCloud email address as Status Target :

m = mail.MailNotifier(fromaddr="[email protected]",
                  sendToInterestedUsers=False,
                  extraRecipients=["[email protected]"],
                  useTls=True, relayhost="smtp.mail.me.com", smtpPort=587,
                  smtpUser="[email protected]", smtpPassword="some_icloud_password")

(the iCloud email setup instructions are here).

Seems like there's something wrong with the TLS/SSL handshake (from master/twistd.log) :

2014-06-09 00:43:34-0700 [ESMTPSender,client] SMTP Client retrying server. Retry: 1
2014-06-09 00:43:34-0700 [ESMTPSender,client] Unhandled Error
    Traceback (most recent call last):
      File "/Users/ionut/work/buildbot/sandbox/lib/python2.7/site-packages/Twisted-14.0.0-py2.7-macosx-10.9-intel.egg/twisted/internet/tcp.py", line 214, in doRead
        return self._dataReceived(data)
      File "/Users/ionut/work/buildbot/sandbox/lib/python2.7/site-packages/Twisted-14.0.0-py2.7-macosx-10.9-intel.egg/twisted/internet/tcp.py", line 220, in _dataReceived
        rval = self.protocol.dataReceived(data)
      File "/Users/ionut/work/buildbot/sandbox/lib/python2.7/site-packages/Twisted-14.0.0-py2.7-macosx-10.9-intel.egg/twisted/protocols/basic.py", line 571, in dataReceived
        why = self.lineReceived(line)
      File "/Users/ionut/work/buildbot/sandbox/lib/python2.7/site-packages/Twisted-14.0.0-py2.7-macosx-10.9-intel.egg/twisted/mail/smtp.py", line 1063, in lineReceived
        why = self._okresponse(self.code,'\n'.join(self.resp))
    --- <exception caught here> ---
      File "/Users/ionut/work/buildbot/sandbox/lib/python2.7/site-packages/Twisted-14.0.0-py2.7-macosx-10.9-intel.egg/twisted/mail/smtp.py", line 1411, in esmtpState_starttls
        self.transport.startTLS(self.context)
    exceptions.AttributeError: 'Client' object has no attribute 'startTLS'
2014-06-09 00:43:34-0700 [ESMTPSender,client] Unhandled error in Deferred:
2014-06-09 00:43:34-0700 [ESMTPSender,client] Unhandled Error
    Traceback (most recent call last):
    Failure: twisted.mail.smtp.TLSError: 451 Could not complete the SSL/TLS handshake
    <<< 250-NO-SOLICITING
    <<< 250 SIZE 28311552
    >>> STARTTLS
    <<< 220 2.5.0 Go ahead with TLS negotiation.

Note : I am NOT able to send email from the command line via "mail" or "sendmail" - I didn't bother since I noticed buildbot has its own email client Python code.

Please help - thank you !


Solution

  • Solved it : since buildbot uses virtualenv, I needed to install pyOpenSSL via easy_install - in the directory that contains the local python env (i.e., the "sandbox") I ran "easy_install pyopenssl" and the SSL handshake proceeded correctly, so buildbot can send emails now. Initially, I "installed" pyOpenSSL by linking to the SSL directory from inside the system Python framework. Looks like the buildbot install script doesn't install pyOpenSSL, weird. Thank you !