'Error when trying to send email using gmail from buildbot docker image

I am trying to the buildbot/buildbot-master:latest docker image for my CI environment als it works like a charm except when trying to send emails.

I use the following email configuration:

from emailLookup import EmailLookup
mn = reporters.MailNotifier(
    fromaddr='[email protected]',
    sendToInterestedUsers=True,
    extraRecipients=[],
    relayhost='smtp.gmail.com',
    smtpPort=587,
    useTls=True,
    smtpUser=private.auth_username,
    smtpPassword=private.auth_password,
    lookup=EmailLookup(),
    generators=[generator],
)

c['services'].append(mn)

and get the following error message:

2022-03-11 14:04:03+0000 [ESMTPSender,client] Got exception when handling reporter events
    Traceback (most recent call last):
      File "/buildbot_venv/lib/python3.9/site-packages/twisted/internet/defer.py", line 1750, in gotResult
        current_context.run(_inlineCallbacks, r, gen, status)
      File "/buildbot_venv/lib/python3.9/site-packages/twisted/internet/defer.py", line 1656, in _inlineCallbacks
        result = current_context.run(
      File "/buildbot_venv/lib/python3.9/site-packages/twisted/python/failure.py", line 489, in throwExceptionIntoGenerator
        return g.throw(self.type, self.value, self.tb)
      File "/buildbot_venv/lib/python3.9/site-packages/buildbot/reporters/base.py", line 95, in _got_event
        log.err(e, 'Got exception when handling reporter events')
    --- <exception caught here> ---
      File "/buildbot_venv/lib/python3.9/site-packages/buildbot/reporters/base.py", line 93, in _got_event
        yield self.sendMessage(reports)
    twisted.mail._except.TLSRequiredError: 502 Server does not support secure communication via TLS / SSL
    <<< 250-smtp.gmail.com at your service, [62.99.227.122]
    <<< 250-SIZE 35882577
    <<< 250-8BITMIME
    <<< 250-STARTTLS
    <<< 250-ENHANCEDSTATUSCODES
    <<< 250-PIPELINING
    <<< 250-CHUNKING
    <<< 250 SMTPUTF8

Any help is appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source