diff --git a/mail/send_mail.anubis b/mail/send_mail.anubis index 6159f80..19196a9 100644 --- a/mail/send_mail.anubis +++ b/mail/send_mail.anubis @@ -38,7 +38,7 @@ define Int _sendmail_time_out = 300. //5 minutes of timeout public type Smtp_Recipient: smtp_recipient(String email, //email address of the recipient - Int nb_tries, + Send_Tries nb_tries, Int uid, //parameter used by handle_status (mail_uid) Int uid2 //same (contact_id) ). @@ -48,7 +48,7 @@ public type Smtp_Recipient: public type Send_Param: send_param( Str_HostName host_name, //domain of the sender like "mail.calexium.com" Str_Sender sender, //sender email address - List(Data_IO) mail_parts, //all parts of the email to send + List(Data_IO) mail_parts, //all parts of the email to send List(Smtp_Recipient) recipients, //recipient email address SmtpAuth auth, // Str_UID mail_uid, @@ -110,7 +110,8 @@ define Result(SmtpClientResult, One) SmtpClientSession sm_session, //smtp session (Int) -> One progress_report, //don't know what it is for the moment (LogLevel, String) -> One logger, //logger - (Result(SmtpClientResult, One), Smtp_Recipient) -> One handle_result + (Result(SmtpClientResult, One), Smtp_Recipient) -> One handle_result, + Bool unique_recipient )= if recipients is { @@ -123,9 +124,12 @@ define Result(SmtpClientResult, One) //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) + send_to_recipients_list(conn, param, tail, sm_session, progress_report, logger, handle_result, unique_recipient) else - ok(unique) + if unique_recipient then + result + else + ok(unique) } . @@ -169,7 +173,11 @@ public define Result(SmtpClientResult, One) { error(prepare_result) then error(prepare_result), ok(new_param) then - with result = send_to_recipients_list(conn, new_param, new_param.recipients, sm_session, progress_report, logger, handle_result), + with result = + if length(new_param.recipients) > 1 then + send_to_recipients_list(conn, new_param, new_param.recipients, sm_session, progress_report, logger, handle_result, false) + else + send_to_recipients_list(conn, new_param, new_param.recipients, sm_session, progress_report, logger, handle_result, true), send_quit(conn, sm_session, _sendmail_time_out, logger); result } @@ -238,7 +246,7 @@ public define Result(SmtpClientResult, One) error(error), ok(server_conn) then - send_mail(server_conn, param, (Result(SmtpClientResult, One) dum, Smtp_Recipient my) |-> unique), + send_mail(server_conn, param, (Result(SmtpClientResult, One) dum, Smtp_Recipient my) |-> println("send_mail Result(SmtpClientResult, One) ignored ")), } }. diff --git a/mail/send_mail_type.anubis b/mail/send_mail_type.anubis index fc047f0..69c1996 100644 --- a/mail/send_mail_type.anubis +++ b/mail/send_mail_type.anubis @@ -23,6 +23,9 @@ public type Str_Recipient: public type Str_UID: str_UID(String str). + +public type Send_Tries: + send_tries(Int number). public type Send_Status: ready, //ready to send -- libgit2 0.21.4