From: Jean-Marc Pigeon (Delson) Date: Fri, 13 Jun 2025 14:32:59 +0000 (-0400) Subject: Working on eml_do_warning X-Git-Tag: tag-0.8~8 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=2c3f3359694c2204e0bb19b9ad7fbc3f21450a98;p=jmp%2Fmailleur Working on eml_do_warning --- diff --git a/Makefile b/Makefile index a31216c..e354d97 100644 --- 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 \ diff --git a/lib/Makefile b/lib/Makefile index 615702d..d6e6cce 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -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: \ diff --git a/lib/geseml.c b/lib/geseml.c index 73d6d5d..7f4cdac 100644 --- a/lib/geseml.c +++ b/lib/geseml.c @@ -12,8 +12,10 @@ #include #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 +} diff --git a/lib/geseml.h b/lib/geseml.h index 76f533a..31d1be4 100644 --- a/lib/geseml.h +++ b/lib/geseml.h @@ -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