diff --git a/calexium_lib/mail/send_mail.anubis b/calexium_lib/mail/send_mail.anubis index ea7794d..1d261f0 100644 --- a/calexium_lib/mail/send_mail.anubis +++ b/calexium_lib/mail/send_mail.anubis @@ -119,6 +119,8 @@ public define Result(SmtpClientResult, One) { error then error(error), timeout then error(timeout), + no_auth_method then error(no_auth_method), + bad_reply then error(bad_reply), reply(code, status, lines) then if code = 220 then //send EHLO diff --git a/calexium_lib/mail/smtp_client.anubis b/calexium_lib/mail/smtp_client.anubis index e2e8f07..447ddbc 100644 --- a/calexium_lib/mail/smtp_client.anubis +++ b/calexium_lib/mail/smtp_client.anubis @@ -24,6 +24,8 @@ define ByteArray crlf_dot_crlf = to_byte_array(implode([13,10,'.',13,10])). public type SmtpClientResult: error, timeout, + no_auth_method, + bad_reply, reply(Int code, String enhanced_status, List(String) lines). public type SmtpClientSession: @@ -149,12 +151,12 @@ define SmtpClientResult if length(line) =< 3 then if decimal_scan(line) is { - failure then logger(logError, "receive_reply: can't extract reply code from '" + line + "'"); error, + failure then logger(logError, "receive_reply: can't extract reply code from '" + line + "'"); bad_reply, success(code) then reply_handling(code, reverse(so_far), enhanced_status) } else if nth(3, line) is { - failure then logger(logError, "receive_reply: error getting 4th character from '" + line +"'"); error, + failure then logger(logError, "receive_reply: error getting 4th character from '" + line +"'"); bad_reply, success(char) then if char = '-' then receive_reply(conn, [line . so_far], enhanced_status, time_out, logger) @@ -162,11 +164,11 @@ define SmtpClientResult //decode the code if sub_string(line, 0, 3) is { - failure then logger(logError, "receive_reply: error extracting reply code from '" + line+"'"); error, // should never occure + failure then logger(logError, "receive_reply: error extracting reply code from '" + line+"'"); bad_reply, // should never occure success(code_str) then if decimal_scan(code_str) is { - failure then logger(logError, "receive_reply: can't extract reply code from '" + code_str + "'"); error, //unreadable code + failure then logger(logError, "receive_reply: can't extract reply code from '" + code_str + "'"); bad_reply, //unreadable code success(code) then reply_handling(code , reverse([line . so_far]), enhanced_status) } @@ -458,6 +460,8 @@ define SendContentResult copy_ok(so_far + len) } }, + no_auth_method then copy_error(so_far), // impossible + bad_reply then copy_error(so_far), reply(code, status, lines) then smtp_reply(reply(code, status, lines)) }. @@ -633,6 +637,8 @@ public define Result(SmtpClientResult, One) { error then "", timeout then "", + no_auth_method then "", + bad_reply then "", reply(code, status, lines) then if lines is [h . _] then if split(h, ' ') is [_ . t] then @@ -672,7 +678,7 @@ public define Result(SmtpClientResult, One) do_auth_login(conn, login, password, session, timeout, logger) else - logger(logError, "do_login: none of CRAM-MD5, LOGIN or PLAIN method available"); error(error). + logger(logError, "do_login: none of CRAM-MD5, LOGIN or PLAIN method available"); error(no_auth_method). public define Result(SmtpClientResult, One) do_auth @@ -690,7 +696,7 @@ public define Result(SmtpClientResult, One) with auth_list = get_auth_method(session.ehlo_answer, []), if auth_list is { - [] then logger(logError, "do_auth error"); error(error), + [] then logger(logError, "do_auth error"); error(no_auth_method), [_ . _] then do_login(conn, auth_list, user, password, session, timeout, logger) } }. -- libgit2 0.21.4