diff options
author | David Rousselie <dax@happycoders.org> | 2007-11-07 21:06:13 +0300 |
---|---|---|
committer | David Rousselie <dax@happycoders.org> | 2007-11-07 21:06:13 +0300 |
commit | a901a23fb44d8fa12fac35966d51b2ca715cf7c7 (patch) | |
tree | 4cb155fa0cc49db5464d51b08dd64ba93e66465f /src/jmc/model | |
parent | 6a8afaedd0b6d16f3cbc528462c2c2845d988b8c (diff) |
Support more email header in Jabber message sent to JMC
darcs-hash:20071107180613-86b55-86d24b561b19d12378f5469be31c328940d0fd88.gz
Diffstat (limited to 'src/jmc/model')
-rw-r--r-- | src/jmc/model/account.py | 5 | ||||
-rw-r--r-- | src/jmc/model/tests/account.py | 19 |
2 files changed, 23 insertions, 1 deletions
diff --git a/src/jmc/model/account.py b/src/jmc/model/account.py index 7346eae..da171fa 100644 --- a/src/jmc/model/account.py +++ b/src/jmc/model/account.py @@ -717,7 +717,7 @@ class SMTPAccount(Account): get_register_fields = classmethod(_get_register_fields) - def create_email(self, from_email, to_email, subject, body): + def create_email(self, from_email, to_email, subject, body, other_headers=None): """Create new email""" email = MIMEText(body) if subject is None: @@ -725,6 +725,9 @@ class SMTPAccount(Account): email['Subject'] = Header(str(subject)) email['From'] = Header(str(from_email)) email['To'] = Header(str(to_email)) + if other_headers is not None: + for header_name in other_headers.keys(): + email[header_name] = Header(other_headers[header_name]) return email def __say_hello(self, connection): diff --git a/src/jmc/model/tests/account.py b/src/jmc/model/tests/account.py index 5df4d5e..1afc7fb 100644 --- a/src/jmc/model/tests/account.py +++ b/src/jmc/model/tests/account.py @@ -515,6 +515,25 @@ class SMTPAccount_TestCase(Account_TestCase): self.assertEqual(email['Subject'], "subject") self.assertEqual(email.get_payload(), "body") + def test_create_email_other_headers(self): + model.db_connect() + account11 = SMTPAccount(user=User(jid="user1@test.com"), + name="account11", + jid="account11@jmc.test.com") + model.db_disconnect() + email = account11.create_email("from@test.com", + "to@test.com", + "subject", + "body", + {"Bcc": "bcc@test.com", + "Cc": "cc@test.com"}) + self.assertEqual(email['From'], "from@test.com") + self.assertEqual(email['To'], "to@test.com") + self.assertEqual(email['Subject'], "subject") + self.assertEqual(email['Bcc'], "bcc@test.com") + self.assertEqual(email['Cc'], "cc@test.com") + self.assertEqual(email.get_payload(), "body") + def make_test(self, responses=None, queries=None, core=None): def inner(): self.server = server.DummyServer("localhost", 1025) |