#NEWLINE# def send_simple_message( recipient ) : #NEWLINE# #INDENT# http = httplib2 . Http ( ) #NEWLINE# http . add_credentials ( 'api' , MAILGUN_API_KEY ) #NEWLINE# url = 'https://api.mailgun.net/v3/{}/messages' . format ( MAILGUN_DOMAIN_NAME ) #NEWLINE# data = { #NEWLINE# #INDENT# 'from' : 'Example Sender <mailgun@{}>' . format ( MAILGUN_DOMAIN_NAME ) , #NEWLINE# 'to' : recipient , #NEWLINE# 'subject' : 'This is an example email from Mailgun' , #NEWLINE# 'text' : 'Test message from Mailgun' , #NEWLINE# #UNINDENT# } #NEWLINE# ( resp , content ) = http . request ( data , 'POST' , urlencode ( data ) ) #NEWLINE# if ( resp . status != 200 ) : #NEWLINE# #INDENT# raise RuntimeError ( 'Mailgun API error: {} {}' . format ( resp . status , content ) )