Postmark: handle Reply-To in EmailMessage headers

Move 'Reply-To' header into dedicated Postmark API param

Fixes #39
This commit is contained in:
medmunds
2016-11-01 12:12:21 -07:00
parent e78410eea4
commit 4ca39a976f
2 changed files with 17 additions and 2 deletions

View File

@@ -85,9 +85,9 @@ class PostmarkBackendStandardEmailTests(PostmarkBackendMockAPITestCase):
self.assertEqual(data['To'], 'to1@example.com, Also To <to2@example.com>')
self.assertEqual(data['Bcc'], 'bcc1@example.com, Also BCC <bcc2@example.com>')
self.assertEqual(data['Cc'], 'cc1@example.com, Also CC <cc2@example.com>')
self.assertEqual(data['ReplyTo'], 'another@example.com')
self.assertCountEqual(data['Headers'], [
{'Name': 'Message-ID', 'Value': 'mycustommsgid@sales.example.com'},
{'Name': 'Reply-To', 'Value': 'another@example.com'},
{'Name': 'X-MyHeader', 'Value': 'my value'},
])
@@ -136,6 +136,16 @@ class PostmarkBackendStandardEmailTests(PostmarkBackendMockAPITestCase):
self.assertEqual(data['ReplyTo'], 'reply@example.com, Other <reply2@example.com>')
self.assertEqual(data['Headers'], [{'Name': 'X-Other', 'Value': 'Keep'}]) # don't lose other headers
def test_reply_to_header(self):
# Reply-To needs to be moved out of headers, into dedicated param
email = mail.EmailMessage('Subject', 'Body goes here', 'from@example.com', ['to1@example.com'],
headers={'reply-to': 'reply@example.com, Other <reply2@example.com>',
'X-Other': 'Keep'})
email.send()
data = self.get_api_call_json()
self.assertEqual(data['ReplyTo'], 'reply@example.com, Other <reply2@example.com>')
self.assertEqual(data['Headers'], [{'Name': 'X-Other', 'Value': 'Keep'}]) # don't lose other headers
def test_attachments(self):
text_content = "* Item one\n* Item two\n* Item three"
self.message.attach(filename="test.txt", content=text_content, mimetype="text/plain")