<s> """<STR_LIT>""" <EOL> import logging <EOL> from django . core import mail <EOL> from django . core . mail import SMTPConnection <EOL> from django . conf import settings <EOL> from google . appengine . api import mail as gmail <EOL> class GoogleSMTPConnection ( SMTPConnection ) : <EOL> def __init__ ( self , host = None , port = None , username = None , password = None , <EOL> use_tls = None , fail_silently = False ) : <EOL> self . use_tls = ( use_tls is not None ) and use_tls or settings . EMAIL_USE_TLS <EOL> self . fail_silently = fail_silently <EOL> self . connection = None <EOL> def open ( self ) : <EOL> self . connection = True <EOL> def close ( self ) : <EOL> pass <EOL> def _send ( self , email_message ) : <EOL> """<STR_LIT>""" <EOL> if not email_message . to : <EOL> return False <EOL> try : <EOL> if ( isinstance ( email_message , gmail . EmailMessage ) ) : <EOL> e = message <EOL> elif ( isinstance ( email_message , mail . EmailMessage ) ) : <EOL> e = gmail . EmailMessage ( sender = email_message . from_email , <EOL> to = email_message . to , <EOL> subject = email_message . subject , <EOL> body = email_message . body ) <EOL> if email_message . extra_headers . get ( '<STR_LIT>' , None ) : <EOL> e . reply_to = email_message . extra_headers [ '<STR_LIT>' ] <EOL> if email_message . bcc : <EOL> e . bcc = list ( email_message . bcc ) <EOL> e . send ( ) <EOL> except : <EOL> if not self . fail_silently : <EOL> raise <EOL> return False <EOL> return True <EOL> def mail_admins ( subject , message , fail_silently = False ) : <EOL> """<STR_LIT>""" <EOL> _mail_group ( settings . ADMINS , subject , message , fail_silently ) <EOL> def mail_managers ( subject , message , fail_silently = False ) : <EOL> """<STR_LIT>""" <EOL> _mail_group ( settings . MANAGERS , subject , message , fail_silently ) <EOL> def _mail_group ( group , subject , message , fail_silently = False ) : <EOL> """<STR_LIT>""" <EOL> if group : <EOL> mail . send_mail ( settings . EMAIL_SUBJECT_PREFIX + subject , message , <EOL> settings . SERVER_EMAIL , [ a [ <NUM_LIT:1> ] for a in group ] , <EOL> fail_silently ) <EOL> return <EOL> try : <EOL> gmail . send_mail_to_admins ( settings . SERVER_EMAIL , <EOL> settings . EMAIL_SUBJECT_PREFIX + subject , <EOL> message ) <EOL> except : <EOL> if not fail_silently : <EOL> raise </s>
