#NEWLINE# def upload( self , format , file_name ) : #NEWLINE# #INDENT# from email.mime.base import MIMEBase #NEWLINE# from email.mime.multipart import MIMEMultipart #NEWLINE# import datetime #NEWLINE# from email import encoders #NEWLINE# outer = MIMEMultipart ( ) #NEWLINE# outer [ 'Subject' ] = ( 'Garmin Data Upload from %s' % datetime . date . today ( ) ) #NEWLINE# outer [ 'To' ] = 'upload@strava.com' #NEWLINE# outer [ 'From' ] = self . smtp_username #NEWLINE# outer . preamble = 'You will not see this in a MIME-aware mail reader.\n' #NEWLINE# with open ( file_name , 'rb' ) as fp : #NEWLINE# #INDENT# msg = MIMEBase ( 'application' , 'octet-stream' ) #NEWLINE# msg . set_payload ( fp . read ( ) ) #NEWLINE# #UNINDENT# encoders . encode_base64 ( outer ) #NEWLINE# msg . add_header ( 'Content-Disposition' , 'attachment' , filename = file_name ) #NEWLINE# outer . attach ( msg ) #NEWLINE# self . server . sendmail ( self . smtp_username , 'upload@strava.com' , outer . as_string ( ) )