示例#1
0
文件: account.py 项目: dax/jmc
 def test_send_email_esmtp_no_auth(self):
     model.db_connect()
     smtp_account = SMTPAccount(user=User(jid="*****@*****.**"), name="account11", jid="*****@*****.**")
     smtp_account.host = "localhost"
     smtp_account.port = 1025
     model.db_disconnect()
     email = smtp_account.create_email("*****@*****.**", "*****@*****.**", "subject", "body")
     test_func = self.make_test(
         [
             "220 localhost ESMTP\r\n",
             "250-localhost Hello 127.0.0.1\r\n" + "250-SIZE 52428800\r\n" + "250-PIPELINING\r\n" + "250 HELP\r\n",
             "250 OK\r\n",
             "250 Accepted\r\n",
             "354 Enter message\r\n",
             None,
             None,
             None,
             None,
             None,
             None,
             None,
             None,
             "250 OK\r\n",
         ],
         [
             "ehlo .*\r\n",
             "mail FROM:<" + str(email["From"]) + ">.*",
             "rcpt TO:<" + str(email["To"]) + ">\r\n",
             "data\r\n",
         ]
         + email.as_string().split("\n")
         + [".\r\n"],
         lambda self: smtp_account.send_email(email),
     )
     test_func()
示例#2
0
文件: account.py 项目: dax/jmc
 def test_get_default_status_msg(self):
     """
     Get default status message for IMAPAccount.
     """
     smtp_account = SMTPAccount(user=User(jid="*****@*****.**"), name="account11", jid="*****@*****.**")
     smtp_account.host = "localhost"
     smtp_account.port = 1025
     smtp_account.login = "******"
     smtp_account.password = "******"
     status_msg = smtp_account.get_default_status_msg(Lang.en)
     self.assertEquals(status_msg, "smtp://user@localhost:1025")
示例#3
0
文件: account.py 项目: dax/jmc
 def test_send_email_esmtp_auth_method2(self):
     model.db_connect()
     smtp_account = SMTPAccount(user=User(jid="*****@*****.**"), name="account11", jid="*****@*****.**")
     smtp_account.host = "localhost"
     smtp_account.port = 1025
     smtp_account.login = "******"
     smtp_account.password = "******"
     model.db_disconnect()
     email = smtp_account.create_email("*****@*****.**", "*****@*****.**", "subject", "body")
     test_func = self.make_test(
         [
             "220 localhost ESMTP\r\n",
             "250-localhost Hello 127.0.0.1\r\n"
             + "250-SIZE 52428800\r\n"
             + "250-AUTH PLAIN LOGIN CRAM-MD5\r\n"
             + "250-PIPELINING\r\n"
             + "250 HELP\r\n",
             "334 ZGF4IDNmNDM2NzY0YzBhNjgyMTQ1MzhhZGNiMjE2YTYxZjRm\r\n",
             "535 Incorrect Authentication data\r\n",
             "334 asd235r4\r\n",
             "235 Authentication succeeded\r\n",
             "250 OK\r\n",
             "250 Accepted\r\n",
             "354 Enter message\r\n",
             None,
             None,
             None,
             None,
             None,
             None,
             None,
             None,
             "250 OK\r\n",
         ],
         [
             "ehlo .*\r\n",
             "AUTH CRAM-MD5\r\n",
             ".*\r\n",
             "AUTH LOGIN .*\r\n",
             ".*\r\n",
             "mail FROM:<" + str(email["From"]) + ">.*",
             "rcpt TO:<" + str(email["To"]) + ">\r\n",
             "data\r\n",
         ]
         + email.as_string().split("\n")
         + [".\r\n"],
         lambda self: smtp_account.send_email(email),
     )
     test_func()