From: Jean-Marc Pigeon (Delson) Date: Fri, 9 May 2025 17:44:45 +0000 (-0400) Subject: Detecting rcpt duplicate X-Git-Tag: tag-0.8~114 X-Git-Url: https://jmp-git.ovh.safe.ca/?a=commitdiff_plain;h=d3aef7207286eaebff710501dd8921f5aec62ef1;p=jmp%2Fmailleur Detecting rcpt duplicate --- diff --git a/data-feed/xxfeed.tst b/data-feed/xxfeed.tst index e22830b..64070e5 100644 --- a/data-feed/xxfeed.tst +++ b/data-feed/xxfeed.tst @@ -13,6 +13,8 @@ S:MAIL FROM: R:250 2.1.3 postmaster@example.com.. sender ok S:RCPT TO: R:250 2.6.2 Address accepted +S:RCPT TO: +R:250 2.6.2 duplicate recipients will be consolidated S:RCPT TO: R:250 2.6.2 Address accepted #------------------------------------------------------------------------- diff --git a/lib/lvleml.c b/lib/lvleml.c index a06e222..f652329 100644 --- a/lib/lvleml.c +++ b/lib/lvleml.c @@ -459,10 +459,12 @@ static _Bool checkto(CONTYP *contact,char *rcptto) { _Bool success; +const char *detail; _Bool proceed; int phase; success=false; +detail="Address accepted"; proceed=true; phase=0; while (proceed==true) { @@ -484,11 +486,12 @@ while (proceed==true) { (void) memmove(rcptto,rcptto+1,strlen(rcptto)); break; case 2 : //Storing rcpt to - contact->rcptto=(char **)rou_addlist((void **)contact->rcptto, - (void *)strdup(rcptto)); + if (eml_addemail(&(contact->rcptto),rcptto)==false) { + detail="duplicate recipients will be consolidated"; + } break; case 3 : //everything ok - (void) transmit(contact,"%d 2.6.2 Address accepted",CMDOK); + (void) transmit(contact,"%d 2.6.2 %s",CMDOK,detail); break; default : //SAFE guard proceed=false; diff --git a/lib/unieml.c b/lib/unieml.c index f7f2d30..5e0551c 100644 --- a/lib/unieml.c +++ b/lib/unieml.c @@ -271,3 +271,34 @@ if ((status=fclose(qfile))<0) { return status; #undef OPEP } +/* +^L +*/ +/********************************************************/ +/* */ +/* Procedure to store an email to a list of email */ +/* retune true if successful, false otherwise. */ +/* */ +/********************************************************/ +PUBLIC _Bool eml_addemail(char ***emails,char *email) + +{ +_Bool status; +char **ptr; + +status=true; +ptr=*emails; +if (ptr!=(char **)0) { + while (*ptr!=(char *)0) { + if (strcasecmp(*ptr,email)==0) { + status=false; + break; //already within list + } + ptr++; + } + } +if (status==true) + *emails=(char **)rou_addlist((void **)*emails,strdup(email)); +return status; +} + diff --git a/lib/unieml.h b/lib/unieml.h index 6b40151..a3a7953 100644 --- a/lib/unieml.h +++ b/lib/unieml.h @@ -56,4 +56,8 @@ extern FILE *eml_createqfile(char *qfilename,char *ext); //procedure to close a file within the queue directory extern int eml_closeqfile(FILE *qfile); +//procedure to add an email address to a chain +//of email address +extern _Bool eml_addemail(char ***emails,char *email); + #endif