]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Working on eml_do_warning
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Fri, 13 Jun 2025 14:32:59 +0000 (10:32 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Fri, 13 Jun 2025 14:32:59 +0000 (10:32 -0400)
Makefile
lib/Makefile
lib/geseml.c
lib/geseml.h

index a31216cf120d44e6abb00a8470bd05bbbc58a959..e354d974bb3f54deeb8de384138fa69724b09398 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -45,7 +45,9 @@ dosorter:
                   -r $(TESTDIR) 
 
 donesort:
-          @ bin/sorter                                 \
+          @ gdb                                        \
+               --args                                  \
+           bin/sorter                                  \
                   -f                                   \
                   -d 2                                 \
                   -c ./conf/mailleur.conf.dvl          \
index 615702d77a1a7ccaa8dcfdc9bb73a731f1498e73..d6e6ccefe37045cf35d8a019b2b670acc8c7bde5 100644 (file)
@@ -48,7 +48,7 @@ gesspf.o:                                     \
 
 geseml.o:                                      \
           subrou.h                             \
-          unieml.h                             \
+          unidns.h unieml.h unipar.h unitls.h  \
           geseml.h geseml.h
 
 gestcp.o:                                      \
index 73d6d5d8e91c77b0bc355dc8caf067089986f487..7f4cdacb69496d92643ef05e49f733b8df09ce95 100644 (file)
 #include        <uuid/uuid.h>
 
 #include       "subrou.h"
+#include       "unidns.h"
 #include       "unieml.h"
 #include       "unipar.h"
+#include       "unitls.h"
 #include       "geseml.h"
 
 //dovecot local storage directory
@@ -513,7 +515,7 @@ if (list!=(TRATYP **)0) {
           }
         break;
       case 'W'  :       //need to send a warning
-        (void) rou_alert(0,"%s JMPDBG need to do warning  <%s>",OPEP,(*ptr)->sessid);
+        (void) eml_do_warning(*ptr);
         break;
       default   :
         break;
@@ -752,3 +754,75 @@ if (list!=(TRATYP **)0) {
   }
 return result;
 }
+/*
+^L
+*/
+/********************************************************/
+/*                                                      */
+/*     Procedure to build a waring/reply about an      */
+/*      unsuccessfull email sending. The Email is sent  */
+/*      back to the originator.                         */
+/*                                                      */
+/********************************************************/
+PUBLIC _Bool eml_do_warning(TRATYP *tra)
+
+{
+#define OPEP    "geseml.c:eml_do_warning,"
+
+_Bool done;
+int phase;
+_Bool proceed;
+
+done=false;
+phase=0;
+proceed=true;
+while (proceed==true) {
+  (void) rou_alert(0,"JMPDBG %s phase='%d'",OPEP,phase);
+  switch (phase) {
+    case 0      :       //check if email is FROM local or remote
+      char *domain;
+      int status;
+
+      domain=strchr(tra->mailfrom,'@');
+      status=dns_is_domain_local(domain,tls_get_bind_afn());
+      switch (status) {
+        case dns_local  :
+          tra->code='L';
+          break;
+        case dns_remote :
+          tra->code='R';
+          break;
+        case dns_nomx   :       //Should NEVER ever occur
+          (void) rou_alert(0,"%s Unable to find MX for domain<%s> (bug?)",
+                              OPEP,status,domain);
+          phase=999;
+          break;
+        default         :
+          (void) rou_alert(0,"%s Unexpected status='%d' for domain<%s> (bug?)",
+                              OPEP,status,domain);
+          phase=999;
+          break;                
+        }
+      break;
+    case 1      :       //reversing originator/recipient
+      char dname[60];
+      char orig[100];
+
+      (void) memset(&dname,'\000',sizeof(dname));
+      (void) getdomainname(dname,sizeof(dname)); 
+      (void) snprintf(orig,sizeof(orig),"%s@%s","noreply",dname);
+      tra->rcptto=rou_freestr(tra->rcptto);
+      tra->rcptto=tra->mailfrom;
+      tra->mailfrom=strdup(orig);
+      done=true;
+      break;
+    default     :       //SAFE Guard
+      proceed=false;
+      break;
+    }
+  phase++;
+  }
+return done;
+
+#undef  OPEP
+}
index 76f533ab5ce0366f21c4ab6c6977c96d8d5c42a3..31d1be4863eca4dc3337aeb57b9cf5ac98526662 100644 (file)
@@ -60,4 +60,7 @@ extern _Bool eml_start_sender(char *todo);
 //procedure to sort a transmission list according sessionid
 extern _Bool eml_sort_list(TRATYP **List);
 
+//procedure to build a warning/reply from the transfer record
+extern _Bool eml_do_warning(TRATYP *tra);
+
 #endif