コード例 #1
0
 def click_send_later(self):
     message = EmailMessage(self.sender.login, self.mailToEdit.text(),
                            self.subjectEdit.text(),
                            self.bodyEdit.toPlainText(), self.attachments)
     datetime_object = datetime.strptime(self.sendDate.text(),
                                         '%d.%m %H:%M')
     if datetime_object is None:
         self.sendStatus.setText("Bad date format. Enter %d.%m %H:%M")
     MailSender.save_message(message, datetime_object)
     self.sendStatus.setText("Saved as {0}".format(filename))
コード例 #2
0
 def setUp(self):
     self.login = good_login
     self.password = good_password
     self.credentials = ("smtp.yandex.ru", "465")
     self.msg_content = ("some subject", "some body")
     self.recipient = recipient
     self.sender = MailSender(self.credentials, self.login, self.password)
コード例 #3
0
 def test_daemon_sending(self):
     message = EmailMessage(self.login, self.recipient, *self.msg_content)
     filename = MailSender.save_message(message, datetime.now())
     self.assertTrue(os.path.isfile("./" + messages_dir + "/" + filename))
     format_str = "python DaemonSender.py {0} {1} {2} {3}"
     start_string = format_str.format(self.credentials[0],
                                      self.credentials[1], self.login,
                                      self.password)
     subprocess.Popen(start_string,
                      creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
     self.assertFalse(os.path.isfile(filename))
コード例 #4
0
 def __init__(self, server_credentials: tuple, login, password):
     self.sender = MailSender(server_credentials, login, password)
     self.server_credentials = server_credentials
     self.login = login
     self.password = password
     self.msg_files = self._get_dates_to_files()
コード例 #5
0
 def test_save_message(self):
     message = EmailMessage(self.login, self.recipient, *self.msg_content)
     datetime_object = datetime.now()
     filename = MailSender.save_message(message, datetime_object)
     self.assertTrue(os.path.isfile("./" + messages_dir + "/" + filename))
コード例 #6
0
 def test_authorization_good(self):
     sender = MailSender(self.credentials, self.good_login,
                         self.good_password)
     sender.sock = sender._get_connection(
         (self.credentials[0], int(self.credentials[1])))
     self.assertEqual(sender.authorize(), True)
コード例 #7
0
    def test_authorization_bad(self):
        sender = MailSender(self.credentials, self.bad_login,
                            self.bad_password)

        self.assertRaises(Exception, sender.__enter__)