]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Detecting rcpt duplicate
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Fri, 9 May 2025 17:44:45 +0000 (13:44 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Fri, 9 May 2025 17:44:45 +0000 (13:44 -0400)
data-feed/xxfeed.tst
lib/lvleml.c
lib/unieml.c
lib/unieml.h

index e22830bd35a80ed109455120687f371c979dd468..64070e5815d77d594ba7071c32b2afc01db3d52c 100644 (file)
@@ -13,6 +13,8 @@ S:MAIL FROM: <postmaster@example.com>
 R:250 2.1.3 postmaster@example.com.. sender ok
 S:RCPT TO: <postmaster@example.com>
 R:250 2.6.2 Address accepted
+S:RCPT TO: <postmaster@example.com>
+R:250 2.6.2 duplicate recipients will be consolidated
 S:RCPT TO: <webmaster@example.com>
 R:250 2.6.2 Address accepted
 #-------------------------------------------------------------------------
index a06e222b6b3977092f41a970d17d71886b029637..f6523295cc7f0b05067bd1544949f7245ee1e461 100644 (file)
@@ -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;
index f7f2d30623fd77444ff76a795e28db41560cb927..5e0551cb9ae63d118bbd338897f63492e5f4cdb1 100644 (file)
@@ -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;
+}
+
index 6b4015138d30cad8219cccad041eec5c714e47a8..a3a7953fed072eed8ab832f248c5e3fb32cd898b 100644 (file)
@@ -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