def test_sendMessage(self): """ Ensure that we can send messages successfully. """ # Prepare fromPack = config['extra']['mail_support'] toPack = config['extra']['mail_test'] subject = store.makeRandomString(16) # Send message mail.sendMessage(fromPack, toPack, subject, '') # Check that the message exists on the server server = imaplib.IMAP4(toPack['imap']) server.login(toPack['username'], toPack['password']) server.select() self.assertNotEqual(server.search(None, '(SUBJECT "%s")' % subject)[1], [''])
confirmation.when_expired = datetime.datetime.now() + datetime.timedelta(days=parameter.TICKET_LIFESPAN_IN_DAYS) meta.Session.add(confirmation) meta.Session.commit() # Prepare recipient toByValue = dict(nickname=form['nickname'], email=form['email']) # Prepare subject subject = '[%s] Confirm %s' % (parameter.SITE_NAME, action) # Prepare body c.ticket = confirmation.ticket c.when_expired = confirmation.when_expired c.username = form['username'] c.action = action body = render(templatePath) # Send try: mail.sendMessage(config['extra']['mail_support'], toByValue, subject, body) except mail.Error: return dict(isOk=0, errorByID={ 'status': 'Unable to send confirmation email; please try again later.' }) # Return return {'isOk': 1} def purgeExpiredPersonConfirmations(): """ Delete confirmations that have expired """ meta.Session.execute(model.person_confirmations_table.delete().where(model.PersonConfirmation.when_expired<datetime.datetime.now())) def executePersonConfirmation(ticket):