@@ -145,23 +145,6 @@ def test_name_addr(self):
145145 )
146146
147147 def test_custom_headers (self ):
148- email = mail .EmailMessage (
149- "Subject" ,
150- "Body goes here" ,
151- "from@example.com" ,
152- ["to1@example.com" ],
153- headers = {
154- "Reply-To" : "another@example.com" ,
155- "In-Reply-To" : "12345@example.com" ,
156- "X-MyHeader" : "my value" ,
157- "Message-ID" : "mycustommsgid@example.com" ,
158- "Precedence" : "Bulk" ,
159- },
160- )
161- with self .assertRaisesMessage (AnymailUnsupportedFeature , "extra_headers" ):
162- email .send ()
163-
164- def test_supported_custom_headers (self ):
165148 email = mail .EmailMessage (
166149 "Subject" ,
167150 "Body goes here" ,
@@ -171,13 +154,20 @@ def test_supported_custom_headers(self):
171154 "Reply-To" : "another@example.com" ,
172155 "In-Reply-To" : "12345@example.com" ,
173156 "Precedence" : "Bulk" ,
157+ # Other custom headers only available to enterprise accounts:
158+ "X-Custom" : "custom header" ,
174159 },
175160 )
176161 email .send ()
177162 data = self .get_api_call_json ()
163+ # Special handling headers:
178164 self .assertEqual (data ["reply_to" ], {"email" : "another@example.com" })
179165 self .assertEqual (data ["in_reply_to" ], "12345@example.com" )
180166 self .assertIs (data ["precedence_bulk" ], True )
167+ # Other headers:
168+ self .assertEqual (
169+ data ["headers" ], [{"name" : "X-Custom" , "value" : "custom header" }]
170+ )
181171
182172 def test_html_message (self ):
183173 text_content = "This is an important message."
@@ -607,6 +597,7 @@ def test_default_omits_options(self):
607597 self .assertNotIn ("reply_to" , data )
608598 self .assertNotIn ("html" , data )
609599 self .assertNotIn ("attachments" , data )
600+ self .assertNotIn ("headers" , data )
610601 self .assertNotIn ("template_id" , data )
611602 self .assertNotIn ("tags" , data )
612603 self .assertNotIn ("variables" , data )
0 commit comments