From 82217d228be5a6b934ff33dfecddc5cc6d3ada84 Mon Sep 17 00:00:00 2001 From: totoro Date: Sun, 22 Dec 2019 20:49:44 +0100 Subject: [PATCH] change the logger from sendmail to cxm_lib During sending email, if RSET fail, give up of sending --- mail/send_mail.anubis | 23 ++++++++++++++--------- mail/smtp_client.anubis | 5 +++-- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/mail/send_mail.anubis b/mail/send_mail.anubis index 48852ea..2338081 100644 --- a/mail/send_mail.anubis +++ b/mail/send_mail.anubis @@ -25,6 +25,8 @@ read authentication.anubis read smtp_client.anubis public define String send_mail_log = "SendMail". +public define String cxm_lib = "cxm_lib". + public define LogMask send_mail_mask = logMask("send_mail"). define Int _sendmail_time_out = 300. //5 minutes of timeout @@ -128,8 +130,11 @@ define Result(SmtpClientResult, One) //if there is another recipient we send a RSET and we are able to send the //email to the next recipient within the same smtp session if length(tail) > 0 then - send_rset(conn, sm_session, _sendmail_time_out, logger); - send_to_recipients_list(conn, param, tail, sm_session, progress_report, logger, handle_result, unique_recipient) + if send_rset(conn, sm_session, _sendmail_time_out, logger) is + { + error(result) then error(result), + ok(_) then send_to_recipients_list(conn, param, tail, sm_session, progress_report, logger, handle_result, unique_recipient) + } else if unique_recipient then result @@ -209,8 +214,8 @@ public define Result(SmtpClientResult, One) param, prepare_mail_callback, (Int _) |-> unique, - (LogLevel level, String txt) |-> if level is logTrace then logTrace(send_mail_log, send_mail_log, send_mail_mask, txt) - else log(send_mail_log, level, send_mail_log, txt), + (LogLevel level, String txt) |-> if level is logTrace then logTrace(cxm_lib, send_mail_log, send_mail_mask, txt) + else log(cxm_lib, level, send_mail_log, txt), handle_result ). @@ -237,18 +242,18 @@ public define Result(SmtpClientResult, One) if resolve_address(server) is { failure then - println("IP address NOT found for Mail server ["+server+"]"); - logWarning(send_mail_log, send_mail_log,"IP address NOT found for Mail server ["+server+"]"); + //println("IP address NOT found for Mail server ["+server+"]"); + logWarning(cxm_lib, send_mail_log,"IP address NOT found for Mail server ["+server+"]"); error(error), success(ip_addr) then with ip_txt = ip_addr_to_string(ip_addr), - logTrace(send_mail_log, send_mail_log, send_mail_mask, "send_mail: Trying to connect to "+ip_txt); - println("send_mail: Trying to connect to "+ip_txt); + logTrace(cxm_lib, send_mail_log, send_mail_mask, "send_mail: Trying to connect to "+ip_txt); + //println("send_mail: Trying to connect to "+ip_txt); if (Result(NetworkConnectError,RWStream))connect(ip_addr, port) is { error(e) then - logTrace(send_mail_log, send_mail_log, send_mail_mask, "send_mail: Can't connect to "+ip_txt); + logWarning(cxm_lib, send_mail_log, "send_mail: Can't connect to "+ip_txt); error(error), ok(server_conn) then diff --git a/mail/smtp_client.anubis b/mail/smtp_client.anubis index 7e25a42..a18072b 100644 --- a/mail/smtp_client.anubis +++ b/mail/smtp_client.anubis @@ -563,7 +563,7 @@ public define One ) = forget(smtp_send_command(conn, "QUIT", 221, session, timeout, logger)). -public define One +public define Result(SmtpClientResult, One) send_rset ( RWStream conn, @@ -571,7 +571,8 @@ public define One Int timeout, (LogLevel, String) -> One logger ) = - forget(smtp_send_command(conn, "RSET", 250, session, timeout, logger)). + smtp_send_command(conn, "RSET", 250, session, timeout, logger) +. define List(String) get_auth_method -- libgit2 0.21.4