From 6741024f9a80ba551c8be11d2746cc4945ec951c Mon Sep 17 00:00:00 2001 From: Cedric RICARD Date: Tue, 23 Dec 2008 16:31:38 +0000 Subject: [PATCH] Added send_mail() wrapper --- calexium_lib/mail/send_mail.anubis | 49 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/calexium_lib/mail/send_mail.anubis b/calexium_lib/mail/send_mail.anubis index 894a070..49379f9 100644 --- a/calexium_lib/mail/send_mail.anubis +++ b/calexium_lib/mail/send_mail.anubis @@ -12,6 +12,7 @@ read tools/connections.anubis read tools/findstring.anubis read tools/printable_tree.anubis read data_base/sqlite.anubis +read network/dns.anubis read network/tools.anubis read system/files.anubis read system/string.anubis @@ -33,15 +34,6 @@ public type SendMailResult: ok, error, reply(Int code, String enhanced_status, List(String) lines). - -public type Send_Status: - ready, //ready to send - finished, //the mail is delivered correctly - timeout, //the mail was not sent in enough time, this is a permanent error - general_error, - error(Int code, String enhanced_status, String text), //this is SMTP permanent error 5xx, we can't deliver the mail - warning(Int code, String enhanced_status, String text), //this is SMTP temporary error 4xx, we can retry with same mail later - in_progress. //We are in sending process, it's like a lock public type Str_HostName: str_host_name(String str). @@ -535,3 +527,42 @@ public define SendMailResult //before anything, then we try to extract the enhanced status if exists for relaying the mail with the ISP reply_handling(code,lines,true) }. + +public define SendMailResult + send_mail + ( + RWStream conn, + Send_Param param, + ) = + send_mail(conn, param, (Send_Mail_Session sm_session, Send_Param param) |-> ok(param)). + +public define SendMailResult + send_mail + ( + String server, + Word32 port, + Send_Param param, + )= + if resolve_address(server) is + { + failure then + logWarning(send_mail_log,"IP address NOT found for Mail server ["+server+"]"); + error, + + success(ip_addr) then + with ip_txt = ip_addr_to_string(ip_addr), + logTrace(send_mail_log, send_mail_mask, "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_mask,"send_mail: Can't connect to "+ip_txt); + error, + + ok(server_conn) then + // + //with status = to_Send_Status(send_mail(db, server_conn, send_param(str_sender(sender), str_recipient(recipient), [make_data_io(source)],auth, str_UID(file_uid) ))), + send_mail(server_conn, param), + } + }. + -- libgit2 0.21.4