+ /* 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.
+ */
+ if (SMTP->is_unfiltered) {
+ scan_errors = 0;
+ }
+ else {
+ 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'] = strdup(
+ "5.7.1 Message rejected by filter");
+ }
+
+ sprintf(result, "550 %s\r\n", msg->cm_fields['0']);
+ }
+
+ else { /* Ok, we'll accept this message. */
+ msgnum = CtdlSubmitMsg(msg, valid, NULL, NULL, "");
+ if (msgnum > 0L) {
+ sprintf(result, "250 2.0.0 Message accepted.\r\n");
+ }
+ else {
+ sprintf(result, "550 5.5.0 Internal delivery error\r\n");
+ }
+ }
+
+ /* For SMTP and ESTMP, just print the result message. For LMTP, we
+ * have to print one result message for each recipient. Since there
+ * is nothing in Citadel which would cause different recipients to
+ * have different results, we can get away with just spitting out the
+ * same message once for each recipient.
+ */
+ if (SMTP->is_lmtp) {
+ for (i=0; i<SMTP->number_of_recipients; ++i) {
+ cprintf("%s", result);
+ }