diff options
author | David Rousselie <david.rousselie@happycoders.org> | 2010-06-09 15:48:44 +0400 |
---|---|---|
committer | David Rousselie <david.rousselie@happycoders.org> | 2010-06-09 15:48:44 +0400 |
commit | c68d23e80182c72b177951bd34315f5298e98d70 (patch) | |
tree | 7ae8bacad69299474af7933c3dd32b2ed03f39ed /src | |
parent | 321d5520545e68a7e396afabf89e1eaa685e6a3e (diff) |
fix unknown SMTP auth method error
Diffstat (limited to 'src')
-rw-r--r-- | src/jmc/model/account.py | 2 | ||||
-rw-r--r-- | src/jmc/model/tests/account.py | 39 |
2 files changed, 40 insertions, 1 deletions
diff --git a/src/jmc/model/account.py b/src/jmc/model/account.py index 10cd470..df30820 100644 --- a/src/jmc/model/account.py +++ b/src/jmc/model/account.py @@ -756,7 +756,7 @@ class GlobalSMTPAccount(AbstractSMTPAccount): self.__logger.debug("Successfuly to authenticate using " + str(auth_method) + " method") break - except smtplib.SMTPAuthenticationError, error: + except (smtplib.SMTPAuthenticationError, smtplib.SMTPException), error: self.__logger.debug("Failed to authenticate using " + str(auth_method) + " method") current_error = error diff --git a/src/jmc/model/tests/account.py b/src/jmc/model/tests/account.py index 6f561c4..cf77376 100644 --- a/src/jmc/model/tests/account.py +++ b/src/jmc/model/tests/account.py @@ -1097,6 +1097,45 @@ class SMTPAccount_TestCase(Account_TestCase): smtp_account.send_email(email)) test_func() + def test_send_email_esmtp_auth_method_with_no_suitable_auth_method_error(self): + model.db_connect() + smtp_account = SMTPAccount(user=User(jid="user1@test.com"), + name="account11", + jid="account11@jmc.test.com") + smtp_account.host = "localhost" + smtp_account.port = 1025 + smtp_account.login = "user" + smtp_account.password = "pass" + model.db_disconnect() + email = smtp_account.create_email("from@test.com", + "to@test.com", + "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 DIGEST-MD5\r\n" + + "250-PIPELINING\r\n" + + "250 HELP\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 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() + def test_get_default_status_msg(self): """ Get default status message for IMAPAccount. |