title: How can I send an email using python logging's SMTPHandler and SSL
body: <p>I'm developing a flask app in which I'd like to send error level logging to an email address. I tried setting up the typical error handler:</p>
  
  <pre><code>mail_handler = SMTPHandler(mailhost=(app.config['MAIL_SERVER'], app.config['MAIL_PORT']),
                             fromaddr=app.config['MAIL_FROM_EMAIL'],
                             toaddrs=['me@my_address.com'],
                             subject='The server died. That sucks... :(',
                             credentials=(app.config['MAIL_USERNAME'], app.config['MAIL_PASSWORD']))
  </code></pre>
  
  <p>Note the configuration values are as set up using <a href="https://pythonhosted.org/Flask-Mail/" rel="noreferrer" title="flask-mail">flask-mail</a>, with <code>MAIL_USE_SSL=True</code> and <code>MAIL_PORT=465</code>.</p>
  
  <p>However, upon invoking an error (on purpose during testing) I get socket timeout errors - other than the port, I can't see how to tell the handler to use SSL. There is a <code>secure=()</code> parameter that can be passed (see <a href="https://docs.python.org/3/library/logging.handlers.html#smtphandler" rel="noreferrer">the SMTPHandler docs</a>) but that specifies us of TLS, not SSL.</p>
  
  <p>Any clues how to do this? Thanks!</p>