Changeset 9306
- Timestamp:
- 7 Oct 2012, 08:32:45 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/smtp.py
r8382 r9306 149 149 return MIMEText(text, 'plain', charset) 150 150 151 def send_mail(from_name, from_addr, rcpt_name, rcpt_addr ,151 def send_mail(from_name, from_addr, rcpt_name, rcpt_addrs, 152 152 subject, body, config=None): 153 153 """Send mail. 154 154 """ 155 155 # format message 156 rcpt_addrs = rcpt_addrs.replace(' ','').split(',') 157 body_to = '' 158 for email in rcpt_addrs: 159 body_to += '%s, ' % encode_address(email, rcpt_name) 156 160 body = encode_body(body) 157 161 body["From"] = encode_address(from_addr, from_name) 158 body["To"] = encode_address(rcpt_addr, rcpt_name)162 body["To"] = body_to.strip(', ') 159 163 body["Subject"] = encode_header_item(subject) 160 164 161 165 mailer = getUtility(IMailService) 162 result = mailer().send(from_addr, [rcpt_addr], body.as_string())166 result = mailer().send(from_addr, rcpt_addrs, body.as_string()) 163 167 return result -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r9305 r9306 1169 1169 self.assertTrue( 1170 1170 'You entered invalid credentials.' in self.browser.contents) 1171 import pdb; pdb.set_trace()1172 1171 # We set the password again 1173 1172 IUserAccount( -
main/waeup.kofa/trunk/src/waeup/kofa/tests/test_smtp.py
r8382 r9306 45 45 # Maybe existing receiver of externally sent mail. If this mail account 46 46 # exists really, it might receive mail from the tests! 47 EXTERNAL_MAIL_RECEIVER = 'no- user@waeup.org'47 EXTERNAL_MAIL_RECEIVER = 'no-reply@waeup.org' 48 48 49 49 # Names of mail deliveries to use when external mail tests are enabled. … … 340 340 341 341 @external_mail_test 342 def test_send_direct_mails(self): 343 # send several mails using direct mail delivery 344 self.app['configuration'].smtp_mailer = EXTERNAL_DIRECT_DELIVERY 345 setSite(self.app) 346 result = send_mail( 347 'test program', 'no-reply@waeup.org', 348 'test mail receiver', 349 '%s, %s' % (EXTERNAL_MAIL_RECEIVER, EXTERNAL_MAIL_RECEIVER), 350 'Test Mail from WAeUP Kofa', 351 'Hi from test mailer!\n\nRegards,\nTest Programme\n' 352 ) 353 import transaction 354 transaction.commit() # The mail is really sent when transactions is 355 # committed 356 self.assertTrue('@' in result) 357 return 358 359 @external_mail_test 342 360 def test_send_queued_mail(self): 343 361 # send mail using queued mail delivery
Note: See TracChangeset for help on using the changeset viewer.