From cd4f9d8d1844b18f2cb02a1e30408a7a8e98743f Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Sun, 29 Jun 2025 08:32:07 -0400 Subject: [PATCH] session is update properly --- data-feed/feed03.tst | 4 ++-- lib/geseml.c | 2 +- lib/lvleml.c | 22 +++++++++++++++++++--- lib/unieml.h | 2 ++ 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/data-feed/feed03.tst b/data-feed/feed03.tst index 3c37c46..94131cf 100644 --- a/data-feed/feed03.tst +++ b/data-feed/feed03.tst @@ -31,8 +31,8 @@ R:250 2.1.0 opening new session... #------------------------------------------------------------------------- S:HELO example.com R:250 mailleur.example.com, link (cleartext) ready,... -S:MAIL FROM: -R:250 2.1.3 trouble@mailref1.example.com.. sender ok +S:MAIL FROM: +R:250 2.1.3 postmaster@mailref1.example.com.. sender ok S:RCPT TO: R:250 2.6.4 Address accepted S:RCPT TO: diff --git a/lib/geseml.c b/lib/geseml.c index 7510dfa..624471f 100644 --- a/lib/geseml.c +++ b/lib/geseml.c @@ -830,7 +830,7 @@ while (proceed==true) { } break; case 1 : //Preparing attachement email - (void) fprintf(qout,"From: %s Email daemon <%s>\n",APPNAME,orig); + (void) fprintf(qout,"%s%s Email daemon <%s>\n",EFROM,APPNAME,orig); (void) fprintf(qout,"To: <%s>\n",tra->mailfrom); (void) fprintf(qout,"Date: %s\n",rou_ascsysstamp(time((time_t *)0))); (void) fprintf(qout,"Subject: %s\n",*(tra->resp)+4); diff --git a/lib/lvleml.c b/lib/lvleml.c index 4657b19..0aca99c 100644 --- a/lib/lvleml.c +++ b/lib/lvleml.c @@ -58,7 +58,6 @@ static void getsessid(CONTYP *contact) if (contact!=(CONTYP *)0) { char *newsid; - (void) freesessid(contact); contact->session=(SESTYP *)calloc(1,sizeof(SESTYP)); newsid=eml_getcursesid(contact->mainsesid,contact->numreset); contact->session=(SESTYP *)calloc(1,sizeof(SESTYP)); @@ -549,10 +548,11 @@ static _Bool getdata(CONTYP *contact) { #define OPEP "lvleml.c:getdata," -#define EXTMP "tmp" +#define EXTMP "tmp" _Bool done; FILE *queue; +_Bool inheader; _Bool completed; u_long total; TIMESPEC start; @@ -561,6 +561,7 @@ _Bool proceed; done=false; queue=(FILE *)0; +inheader=true; completed=false; total=0; phase=0; @@ -603,6 +604,19 @@ while (proceed==true) { break; //exiting loop } total+=got; + if (inheader==true) { + if (strlen(line)==0) + inheader=false; + else { //extracting the sfrom + int max; + + max=strlen(EFROM); + if (strncasecmp(line,EFROM,max)==0) { + contact->session->efrom=rou_freestr(contact->session->efrom); + contact->session->efrom=strdup(line+max); + } + } + } if (strcmp(line,".")==0) { completed=true; } @@ -909,11 +923,12 @@ static _Bool doreset(CONTYP *contact,char *parameter) (void) transmit(contact,true,"%d-%s flushed session %s", CMDOK,LOCSEQ,contact->session->sessid); +(void) freesessid(contact); contact->numreset++; +(void) getsessid(contact); contact->recipients=(RCPTYP **)rou_freelist((void **)(contact->recipients), (genfree_t)eml_freerecipient); contact->mailfrom=rou_freestr(contact->mailfrom); -(void) getsessid(contact); (void) transmit(contact,true,"%d %s opening new session %s", CMDOK,LOCSEQ,contact->session->sessid); return true; @@ -1574,6 +1589,7 @@ while (proceed==true) { code=eml_getcode(line); switch (code) { case c_data : //Peer request to transfer email corps. + proceed=getdata(contact); break; case c_helo : //HELO SMTP protocol diff --git a/lib/unieml.h b/lib/unieml.h index ba17294..962240d 100644 --- a/lib/unieml.h +++ b/lib/unieml.h @@ -10,6 +10,8 @@ #include +#define EFROM "From: " //Then email header from + #define MXMSIZE 52428800 //52 Megabytes #define CRLF "\r\n" //EOL within SMTP protocol #define SIGNON 220 //signon information -- 2.47.3