#NEWLINE# def send( self , to , subject , body , cc = None , attachs = ( ) , mimetype = 'text/plain' , charset = None , _callback = None ) : #NEWLINE# #INDENT# if attachs : #NEWLINE# #INDENT# msg = MIMEMultipart ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# msg = MIMENonMultipart ( * mimetype . split ( '/' , 1 ) ) #NEWLINE# #UNINDENT# msg [ 'From' ] = self . mailfrom #NEWLINE# msg [ 'To' ] = COMMASPACE . join ( to ) #NEWLINE# msg [ 'Date' ] = formatdate ( localtime = True ) #NEWLINE# msg [ 'Subject' ] = subject #NEWLINE# rcpts = to [ : ] #NEWLINE# if cc : #NEWLINE# #INDENT# rcpts . extend ( cc ) #NEWLINE# msg [ 'Cc' ] = COMMASPACE . join ( cc ) #NEWLINE# #UNINDENT# if charset : #NEWLINE# #INDENT# msg . set_charset ( charset ) #NEWLINE# #UNINDENT# if self : #NEWLINE# #INDENT# msg . attach ( MIMEText ( body , 'plain' , ( charset or 'us-ascii' ) ) ) #NEWLINE# for ( attach_name , mimetype , f ) in attachs : #NEWLINE# #INDENT# part = MIMEBase ( * mimetype . split ( '/' ) ) #NEWLINE# part . set_payload ( f . read ( ) ) #NEWLINE# Encoders . encode_base64 ( part ) #NEWLINE# part . add_header ( 'Content-Disposition' , ( 'attachment; filename="%s"' % attach_name ) ) #NEWLINE# msg . attach ( part ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# msg . set_payload ( body ) #NEWLINE# #UNINDENT# if _callback : #NEWLINE# #INDENT# _callback ( to = to , subject = subject , body = body , cc = cc , attach = attachs , msg = msg ) #NEWLINE# #UNINDENT# if self . debug : #NEWLINE# #INDENT# logger . debug ( 'Debug mail sent OK: To=%(mailto)s Cc=%(mailcc)s Subject="%(mailsubject)s" Attachs=%(mailattachs)d' , { #NEWLINE# #INDENT# 'mailto' : to , #NEWLINE# 'mailcc' : cc , #NEWLINE# 'mailsubject' : subject , #NEWLINE# 'mailattachs' : len ( attachs ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# return #NEWLINE# #UNINDENT# dfd = self . _sendmail ( rcpts , msg . as_string ( ) ) #NEWLINE# dfd . addCallbacks ( self . _sent_ok , self . _sent_failed , callbackArgs = [ to , cc , subject , len ( attachs ) ] , errbackArgs = [ to , cc , subject , len ( attachs ) ] ) #NEWLINE# reactor . addSystemEventTrigger ( 'before' , 'shutdown' , ( lambda : dfd ) ) #NEWLINE# return dfd