Commit cf51ddb0dfdc300aa1d11aac8687c50c333d3605
1 parent
3a3efadd
Added 2 new kind of SMTP error : no_auth_method and bad_reply
Showing
2 changed files
with
14 additions
and
6 deletions
Show diff stats
calexium_lib/mail/send_mail.anubis
| ... | ... | @@ -119,6 +119,8 @@ public define Result(SmtpClientResult, One) |
| 119 | 119 | { |
| 120 | 120 | error then error(error), |
| 121 | 121 | timeout then error(timeout), |
| 122 | + no_auth_method then error(no_auth_method), | |
| 123 | + bad_reply then error(bad_reply), | |
| 122 | 124 | reply(code, status, lines) then |
| 123 | 125 | if code = 220 then |
| 124 | 126 | //send EHLO | ... | ... |
calexium_lib/mail/smtp_client.anubis
| ... | ... | @@ -24,6 +24,8 @@ define ByteArray crlf_dot_crlf = to_byte_array(implode([13,10,'.',13,10])). |
| 24 | 24 | public type SmtpClientResult: |
| 25 | 25 | error, |
| 26 | 26 | timeout, |
| 27 | + no_auth_method, | |
| 28 | + bad_reply, | |
| 27 | 29 | reply(Int code, String enhanced_status, List(String) lines). |
| 28 | 30 | |
| 29 | 31 | public type SmtpClientSession: |
| ... | ... | @@ -149,12 +151,12 @@ define SmtpClientResult |
| 149 | 151 | if length(line) =< 3 then |
| 150 | 152 | if decimal_scan(line) is |
| 151 | 153 | { |
| 152 | - failure then logger(logError, "receive_reply: can't extract reply code from '" + line + "'"); error, | |
| 154 | + failure then logger(logError, "receive_reply: can't extract reply code from '" + line + "'"); bad_reply, | |
| 153 | 155 | success(code) then reply_handling(code, reverse(so_far), enhanced_status) |
| 154 | 156 | } |
| 155 | 157 | else if nth(3, line) is |
| 156 | 158 | { |
| 157 | - failure then logger(logError, "receive_reply: error getting 4th character from '" + line +"'"); error, | |
| 159 | + failure then logger(logError, "receive_reply: error getting 4th character from '" + line +"'"); bad_reply, | |
| 158 | 160 | success(char) then |
| 159 | 161 | if char = '-' then |
| 160 | 162 | receive_reply(conn, [line . so_far], enhanced_status, time_out, logger) |
| ... | ... | @@ -162,11 +164,11 @@ define SmtpClientResult |
| 162 | 164 | //decode the code |
| 163 | 165 | if sub_string(line, 0, 3) is |
| 164 | 166 | { |
| 165 | - failure then logger(logError, "receive_reply: error extracting reply code from '" + line+"'"); error, // should never occure | |
| 167 | + failure then logger(logError, "receive_reply: error extracting reply code from '" + line+"'"); bad_reply, // should never occure | |
| 166 | 168 | success(code_str) then |
| 167 | 169 | if decimal_scan(code_str) is |
| 168 | 170 | { |
| 169 | - failure then logger(logError, "receive_reply: can't extract reply code from '" + code_str + "'"); error, //unreadable code | |
| 171 | + failure then logger(logError, "receive_reply: can't extract reply code from '" + code_str + "'"); bad_reply, //unreadable code | |
| 170 | 172 | success(code) then |
| 171 | 173 | reply_handling(code , reverse([line . so_far]), enhanced_status) |
| 172 | 174 | } |
| ... | ... | @@ -458,6 +460,8 @@ define SendContentResult |
| 458 | 460 | copy_ok(so_far + len) |
| 459 | 461 | } |
| 460 | 462 | }, |
| 463 | + no_auth_method then copy_error(so_far), // impossible | |
| 464 | + bad_reply then copy_error(so_far), | |
| 461 | 465 | reply(code, status, lines) then |
| 462 | 466 | smtp_reply(reply(code, status, lines)) |
| 463 | 467 | }. |
| ... | ... | @@ -633,6 +637,8 @@ public define Result(SmtpClientResult, One) |
| 633 | 637 | { |
| 634 | 638 | error then "", |
| 635 | 639 | timeout then "", |
| 640 | + no_auth_method then "", | |
| 641 | + bad_reply then "", | |
| 636 | 642 | reply(code, status, lines) then |
| 637 | 643 | if lines is [h . _] then |
| 638 | 644 | if split(h, ' ') is [_ . t] then |
| ... | ... | @@ -672,7 +678,7 @@ public define Result(SmtpClientResult, One) |
| 672 | 678 | do_auth_login(conn, login, password, session, timeout, logger) |
| 673 | 679 | |
| 674 | 680 | else |
| 675 | - logger(logError, "do_login: none of CRAM-MD5, LOGIN or PLAIN method available"); error(error). | |
| 681 | + logger(logError, "do_login: none of CRAM-MD5, LOGIN or PLAIN method available"); error(no_auth_method). | |
| 676 | 682 | |
| 677 | 683 | public define Result(SmtpClientResult, One) |
| 678 | 684 | do_auth |
| ... | ... | @@ -690,7 +696,7 @@ public define Result(SmtpClientResult, One) |
| 690 | 696 | with auth_list = get_auth_method(session.ehlo_answer, []), |
| 691 | 697 | if auth_list is |
| 692 | 698 | { |
| 693 | - [] then logger(logError, "do_auth error"); error(error), | |
| 699 | + [] then logger(logError, "do_auth error"); error(no_auth_method), | |
| 694 | 700 | [_ . _] then do_login(conn, auth_list, user, password, session, timeout, logger) |
| 695 | 701 | } |
| 696 | 702 | }. | ... | ... |