]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Starting to implement badrcpt report within database
authorJean-Marc Pigeon <jmp@safe.c>
Sat, 20 Sep 2025 09:18:14 +0000 (05:18 -0400)
committerJean-Marc Pigeon <jmp@safe.c>
Sat, 20 Sep 2025 09:18:14 +0000 (05:18 -0400)
lib/lvleml.c

index 03883a8bba056e70da743ff9a8b52d2b4f308224..7c19c6e3e324a55d2eb0e66ab7f2e9147d2f5348 100644 (file)
@@ -1176,8 +1176,6 @@ while (proceed==true) {
   phase++;
   }
 return status;
-
-
 #undef  OPEP
 }
 /*
@@ -1237,6 +1235,44 @@ return status;
 */
 /************************************************/
 /*                                             */
+/*     Procedure to report rcpt problem and    */
+/*      store status within the database.       */
+/*                                             */
+/************************************************/
+static void bad_rcpt(CONTYP *contact,char *rcpt,int smtpcode,char *fmt,...)
+
+{
+va_list args;
+char **resp;
+char *report;
+char *info;
+ACTTYP action;
+
+va_start(args,fmt);
+resp=(char **)0;
+(void) rou_vasprintf(&report,fmt,args);
+(void) rou_asprintf(&info,"%d %s",smtpcode,report);
+(void) rou_alert(0,"JMPDBG info=<%s>",info);
+resp=(char **)rou_addlist((void **)resp,(void *)info);
+(void) memset(&action,'\000',sizeof(ACTTYP));
+action.sessid=contact->session->sessid;
+action.code='X';
+action.reverse=contact->peername;
+action.sfrom=contact->mailfrom;
+action.hfrom="----";
+action.hsubject="----";
+action.rcptto=rcpt;
+action.resp=resp;
+(void) eml_transmit(contact,true,"%s",info);
+resp=(char **)rou_freelist((void **)resp,(genfree_t)rou_freestr);
+report=rou_freestr(report);
+va_end(args);
+}
+/*
+\f
+*/
+/************************************************/
+/*                                             */
 /*     Procedure to send a simple SMTP ccommand*/
 /*      (no need to have the response wording)  */
 /*                                             */
@@ -1763,10 +1799,9 @@ while (proceed==true) {
       break;
     case 4      :       //Do we have a domain MX
       if (setlocdom(contact,neu)==false) {
-        (void) eml_transmit(contact,true,"%d 5.6.4 %s (domain=%s)",
-                                          MISSMX,
-                                          "No valid MX found for recipient "
-                                          "domain name",neu->domain);
+        (void) bad_rcpt(contact,rcptto,MISSMX,"5.6.4 %s (domain=%s)",
+                                              "No valid MX found for recipient "
+                                              "domain name",neu->domain);
         phase=999;      //no need to go further
         }
       break;
@@ -2742,7 +2777,7 @@ return contact;
 /********************************************************/
 /*                                                      */
 /*     Procedure to wait for a remote client.          */
-/*      return the frreed memory contact (NULL pointer) */
+/*      return the fee memory contact (NULL pointer)    */
 /*                                                      */
 /********************************************************/
 PUBLIC CONTYP *eml_dropcontact(CONTYP *contact)