Created
December 2, 2014 14:13
-
-
Save jptoto/af50adc56e26c98be819 to your computer and use it in GitHub Desktop.
Send to Postmark w/ UTF8 Chars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import httplib | |
import json | |
postmark_token = 'API_TOKEN' | |
toRecip = u'''\u2122'''.encode('utf8') | |
url = '/email' | |
msg = { | |
'From': '"JP Toto" <jp@wildbit.com>', | |
'To': 'JP Toto' + toRecip + '<jp@example.com>', | |
'Subject': 'utf8 chars', | |
'TextBody': 'hello!', | |
} | |
body = json.dumps(msg) | |
conn = httplib.HTTPConnection("api.postmarkapp.com", 80) | |
headers = { | |
'Accept': 'application/json', | |
'Content-Type': 'application/json', | |
'X-Postmark-Server-Token': postmark_token | |
} | |
conn.request("POST", "/email", body, headers) | |
response = conn.getresponse() | |
print response.status, response.reason | |
print response.read() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment