X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fserv_smtp.c;h=43896c28092e0f89180028ffc68e0623751c961e;hb=9efc6048ae21ab4e374ac4d22a1e4c50740d48be;hp=6617cc2c4e465376e6e29afd4586ba190fb42624;hpb=c863d53f48099f56f8245083a68e0bf966460971;p=citadel.git diff --git a/citadel/serv_smtp.c b/citadel/serv_smtp.c index 6617cc2c4..43896c280 100644 --- a/citadel/serv_smtp.c +++ b/citadel/serv_smtp.c @@ -457,6 +457,7 @@ void smtp_data(void) { long msgnum; char nowstamp[SIZ]; struct recptypes *valid; + int scan_errors; if (strlen(SMTP->from) == 0) { cprintf("503 Need MAIL command first.\r\n"); @@ -508,17 +509,35 @@ void smtp_data(void) { /* Submit the message into the Citadel system. */ valid = validate_recipients(SMTP->recipients); - msgnum = CtdlSubmitMsg(msg, valid, ""); - CtdlFreeMessage(msg); - phree(valid); - if (msgnum > 0L) { - cprintf("250 Message accepted.\r\n"); + /* If there are modules that want to scan this message before final + * submission (such as virus checkers or spam filters), call them now + * and give them an opportunity to reject the message. + */ + scan_errors = PerformMessageHooks(msg, EVT_SMTPSCAN); + + if (scan_errors > 0) { /* We don't want this message! */ + + if (msg->cm_fields['0'] == NULL) { + msg->cm_fields['0'] = strdoop( + "Message rejected by filter"); + } + + cprintf("552 %s\r\n", msg->cm_fields['0']); } - else { - cprintf("550 Internal delivery error\r\n"); + + else { /* Ok, we'll accept this message. */ + msgnum = CtdlSubmitMsg(msg, valid, ""); + if (msgnum > 0L) { + cprintf("250 Message accepted.\r\n"); + } + else { + cprintf("550 Internal delivery error\r\n"); + } } + CtdlFreeMessage(msg); + phree(valid); smtp_data_clear(); /* clear out the buffers now */ }