Changeset 11778 for main/waeup.kofa/trunk
- Timestamp:
- 12 Aug 2014, 15:49:43 (10 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/smtp.py
r11586 r11778 160 160 161 161 def send_mail(from_name, from_addr, rcpt_name, rcpt_addrs, 162 subject, body, config=None ):162 subject, body, config=None, cc=False): 163 163 """Send mail. 164 164 … … 167 167 168 168 Please note: the `from_addr` given will be used for the reply-to 169 and cc field only. It will _not_ be used for the `from` field, as170 yahoo does not allow non-yahoo servers to deliver mail with169 (and cc) field only. It will _not_ be used for the `from` field, 170 as yahoo does not allow non-yahoo servers to deliver mail with 171 171 ``@yahoo.com`` in the from-field. 172 172 173 173 The from-address set here will be: `FROM_ADDRESS` as set above. 174 175 ``cc`` tells whether we want the from-address to be CCed. This is 176 not the case by default as we easily act as an open relay 177 otherwise. 174 178 175 179 XXX: The hard-coded from-address should be changable or be … … 187 191 body["From"] = sender_addr 188 192 body["To"] = body_to.strip(', ') 189 body["Cc"] = body["Reply-To"] = reply_addr 193 if cc: 194 body["Cc"] = reply_addr 195 body["Reply-To"] = reply_addr 190 196 body["Subject"] = encode_header_item(subject) 191 197 -
main/waeup.kofa/trunk/src/waeup/kofa/tests/test_smtp.py
r11586 r11778 244 244 u'msg: From: A sender <no-reply@waeup.org>', 245 245 u'msg: To: A recipient <recpt@example.com>', 246 # u'msg: Cc: A sender <sender@example.com>', 247 u'msg: Reply-To: A sender <sender@example.com>', 248 u'msg: Subject: A subject', 249 u'msg: ', 250 u'msg: This is a test mail.', 251 u''] 252 ) 253 return 254 255 def test_send_mail_with_cc(self): 256 # with cc=True the message will be CCed to the from address 257 mail_id = send_mail( 258 u'A sender', u'sender@example.com', 259 u'A recipient', u'recpt@example.com', 260 u'A subject', 261 u'This is a test mail.', 262 cc=True) 263 self.assertEqual(mail_id, 'fake-message-id@example.com') 264 self.assertEqual( 265 self.get_fake_smtp_output().split('\n'), 266 [u'Sending email from no-reply@waeup.org to ' 267 u'recpt@example.com, sender@example.com:', 268 u'Message:', 269 u'msg: MIME-Version: 1.0', 270 u'msg: Content-Type: text/plain; charset="us-ascii"', 271 u'msg: Content-Transfer-Encoding: 7bit', 272 u'msg: From: A sender <no-reply@waeup.org>', 273 u'msg: To: A recipient <recpt@example.com>', 246 274 u'msg: Cc: A sender <sender@example.com>', 247 275 u'msg: Reply-To: A sender <sender@example.com>', … … 270 298 u'msg: From: A sender <no-reply@waeup.org>', 271 299 u'msg: To: A recipient <recpt@example.com>', 272 u'msg: Cc: A sender <sender@example.com>',300 # u'msg: Cc: A sender <sender@example.com>', 273 301 u'msg: Reply-To: A sender <sender@example.com>', 274 302 u'msg: Subject: A subject', … … 296 324 u'msg: From: A sender <no-reply@waeup.org>', 297 325 u'msg: To: A recipient <recpt@example.com>', 298 u'msg: Cc: A sender <sender@example.com>',326 # u'msg: Cc: A sender <sender@example.com>', 299 327 u'msg: Reply-To: A sender <sender@example.com>', 300 328 u'msg: Subject: A subject',
Note: See TracChangeset for help on using the changeset viewer.