From 0bbd935c59f8200023848187b6cb85758a0ce4ef Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Thu, 8 Jan 2009 08:04:03 +0000 Subject: [PATCH] New mailproc option: ignore_on_error (defaults to false), if true and the mail proc command (or script) fails (or returns non-zero result code), ignore the message. --- src/sbbs3/mailsrvr.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/sbbs3/mailsrvr.c b/src/sbbs3/mailsrvr.c index 1512229b85..a6afccf2ce 100644 --- a/src/sbbs3/mailsrvr.c +++ b/src/sbbs3/mailsrvr.c @@ -8,7 +8,7 @@ * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2008 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * @@ -108,6 +108,7 @@ struct mailproc { str_list_t to; BOOL passthru; BOOL native; + BOOL ignore_on_error; /* Ignore mail message if cmdline fails */ BOOL disabled; } *mailproc_list; @@ -2347,13 +2348,28 @@ static void smtp_thread(void* arg) ,socket, str); if(mailproc_list[i].native) { - if((j=system(str))!=0) - lprintf(LOG_WARNING,"%04d !SMTP system(%s) returned %d (errno: %d)" + if((j=system(str))!=0) { + lprintf(LOG_NOTICE,"%04d !SMTP system(%s) returned %d (errno: %d)" ,socket, str, j, errno); - } else /* JavaScript */ - js_mailproc(socket, &client, &relay_user, str /* cmdline */ + if(mailproc_list[i].ignore_on_error) { + lprintf(LOG_WARNING,"%04d !SMTP IGNORED MAIL due to mail processor (%s) error: %d" + ,socket, str, j); + msg_handled=TRUE; + } + } + } else { /* JavaScript */ + if(!js_mailproc(socket, &client, &relay_user, str /* cmdline */ ,msgtxt_fname, rcptlst_fname, proc_err_fname - ,sender, sender_addr, reverse_path); + ,sender, sender_addr, reverse_path)) { + lprintf(LOG_NOTICE,"%04d !SMTP JavaScript (%s) failed" + ,socket, str); + if(mailproc_list[i].ignore_on_error) { + lprintf(LOG_WARNING,"%04d !SMTP IGNORED MAIL due to mail processor (%s) failure" + ,socket, str); + msg_handled=TRUE; + } + } + } if(flength(proc_err_fname)>0) break; if(!fexist(msgtxt_fname) || !fexist(rcptlst_fname)) @@ -4388,6 +4404,8 @@ void DLLCALL mail_server(void* arg) iniReadBool(fp,sec_list[i],"native",FALSE); mailproc_list[i].disabled = iniReadBool(fp,sec_list[i],"disabled",FALSE); + mailproc_list[i].ignore_on_error = + iniReadBool(fp,sec_list[i],"ignore_on_error",FALSE); } } iniFreeStringList(sec_list); -- GitLab