Skip to content

Instantly share code, notes, and snippets.

@jptoto
Created December 2, 2014 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jptoto/af50adc56e26c98be819 to your computer and use it in GitHub Desktop.
Save jptoto/af50adc56e26c98be819 to your computer and use it in GitHub Desktop.
Send to Postmark w/ UTF8 Chars
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