#NEWLINE# def _open( self ) : #NEWLINE# #INDENT# '\n        Ensures we have a connection to the email server. Returns whether or\n        not a new connection was required (True or False).\n        ' #NEWLINE# cfg = self . app . config #NEWLINE# connection_class = smtplib . SMTP #NEWLINE# connection = connection_class ( cfg [ 'EMAIL_HOST' ] , cfg [ 'EMAIL_PORT' ] , local_hostname = DNS_NAME . get_fqdn ( ) ) #NEWLINE# if cfg [ 'EMAIL_USE_TLS' ] : #NEWLINE# #INDENT# connection . ehlo ( ) #NEWLINE# connection . starttls ( keyfile = cfg [ 'EMAIL_TLS_KEYFILE' ] , certfile = cfg [ 'EMAIL_TLS_CERTFILE' ] ) #NEWLINE# connection . ehlo ( ) #NEWLINE# #UNINDENT# if ( cfg [ 'EMAIL_HOST_USER' ] and cfg [ 'EMAIL_HOST_PASSWORD' ] ) : #NEWLINE# #INDENT# connection . login ( cfg [ 'EMAIL_HOST_USER' ] , cfg [ 'EMAIL_HOST_PASSWORD' ] ) #NEWLINE# #UNINDENT# return connection