Commit 82217d228be5a6b934ff33dfecddc5cc6d3ada84

Authored by David RENÉ
1 parent f14db237

change the logger from sendmail to cxm_lib

During sending email, if RSET fail, give up of sending
Showing 2 changed files with 17 additions and 11 deletions   Show diff stats
mail/send_mail.anubis
@@ -25,6 +25,8 @@ read authentication.anubis @@ -25,6 +25,8 @@ read authentication.anubis
25 read smtp_client.anubis 25 read smtp_client.anubis
26 26
27 public define String send_mail_log = "SendMail". 27 public define String send_mail_log = "SendMail".
  28 +public define String cxm_lib = "cxm_lib".
  29 +
28 public define LogMask send_mail_mask = logMask("send_mail"). 30 public define LogMask send_mail_mask = logMask("send_mail").
29 31
30 define Int _sendmail_time_out = 300. //5 minutes of timeout 32 define Int _sendmail_time_out = 300. //5 minutes of timeout
@@ -128,8 +130,11 @@ define Result(SmtpClientResult, One) @@ -128,8 +130,11 @@ define Result(SmtpClientResult, One)
128 //if there is another recipient we send a RSET and we are able to send the 130 //if there is another recipient we send a RSET and we are able to send the
129 //email to the next recipient within the same smtp session 131 //email to the next recipient within the same smtp session
130 if length(tail) > 0 then 132 if length(tail) > 0 then
131 - send_rset(conn, sm_session, _sendmail_time_out, logger);  
132 - send_to_recipients_list(conn, param, tail, sm_session, progress_report, logger, handle_result, unique_recipient) 133 + if send_rset(conn, sm_session, _sendmail_time_out, logger) is
  134 + {
  135 + error(result) then error(result),
  136 + ok(_) then send_to_recipients_list(conn, param, tail, sm_session, progress_report, logger, handle_result, unique_recipient)
  137 + }
133 else 138 else
134 if unique_recipient then 139 if unique_recipient then
135 result 140 result
@@ -209,8 +214,8 @@ public define Result(SmtpClientResult, One) @@ -209,8 +214,8 @@ public define Result(SmtpClientResult, One)
209 param, 214 param,
210 prepare_mail_callback, 215 prepare_mail_callback,
211 (Int _) |-> unique, 216 (Int _) |-> unique,
212 - (LogLevel level, String txt) |-> if level is logTrace then logTrace(send_mail_log, send_mail_log, send_mail_mask, txt)  
213 - else log(send_mail_log, level, send_mail_log, txt), 217 + (LogLevel level, String txt) |-> if level is logTrace then logTrace(cxm_lib, send_mail_log, send_mail_mask, txt)
  218 + else log(cxm_lib, level, send_mail_log, txt),
214 handle_result 219 handle_result
215 ). 220 ).
216 221
@@ -237,18 +242,18 @@ public define Result(SmtpClientResult, One) @@ -237,18 +242,18 @@ public define Result(SmtpClientResult, One)
237 if resolve_address(server) is 242 if resolve_address(server) is
238 { 243 {
239 failure then 244 failure then
240 - println("IP address NOT found for Mail server ["+server+"]");  
241 - logWarning(send_mail_log, send_mail_log,"IP address NOT found for Mail server ["+server+"]"); 245 + //println("IP address NOT found for Mail server ["+server+"]");
  246 + logWarning(cxm_lib, send_mail_log,"IP address NOT found for Mail server ["+server+"]");
242 error(error), 247 error(error),
243 248
244 success(ip_addr) then 249 success(ip_addr) then
245 with ip_txt = ip_addr_to_string(ip_addr), 250 with ip_txt = ip_addr_to_string(ip_addr),
246 - logTrace(send_mail_log, send_mail_log, send_mail_mask, "send_mail: Trying to connect to "+ip_txt);  
247 - println("send_mail: Trying to connect to "+ip_txt); 251 + logTrace(cxm_lib, send_mail_log, send_mail_mask, "send_mail: Trying to connect to "+ip_txt);
  252 + //println("send_mail: Trying to connect to "+ip_txt);
248 if (Result(NetworkConnectError,RWStream))connect(ip_addr, port) is 253 if (Result(NetworkConnectError,RWStream))connect(ip_addr, port) is
249 { 254 {
250 error(e) then 255 error(e) then
251 - logTrace(send_mail_log, send_mail_log, send_mail_mask, "send_mail: Can't connect to "+ip_txt); 256 + logWarning(cxm_lib, send_mail_log, "send_mail: Can't connect to "+ip_txt);
252 error(error), 257 error(error),
253 258
254 ok(server_conn) then 259 ok(server_conn) then
mail/smtp_client.anubis
@@ -563,7 +563,7 @@ public define One @@ -563,7 +563,7 @@ public define One
563 ) = 563 ) =
564 forget(smtp_send_command(conn, "QUIT", 221, session, timeout, logger)). 564 forget(smtp_send_command(conn, "QUIT", 221, session, timeout, logger)).
565 565
566 -public define One 566 +public define Result(SmtpClientResult, One)
567 send_rset 567 send_rset
568 ( 568 (
569 RWStream conn, 569 RWStream conn,
@@ -571,7 +571,8 @@ public define One @@ -571,7 +571,8 @@ public define One
571 Int timeout, 571 Int timeout,
572 (LogLevel, String) -> One logger 572 (LogLevel, String) -> One logger
573 ) = 573 ) =
574 - forget(smtp_send_command(conn, "RSET", 250, session, timeout, logger)). 574 + smtp_send_command(conn, "RSET", 250, session, timeout, logger)
  575 +.
575 576
576 define List(String) 577 define List(String)
577 get_auth_method 578 get_auth_method