TESTITER= 4
#--------------------------------------------------------------------
#To test sorter
+dosorter: debug
+ @ bin/sorter \
+ -d 2 \
+ -c ./conf/mailleur.conf.dvl \
+ -r $(TESTDIR)
+
sorter : clean debug
@ rm -fr $(TESTDIR)/var/spool/$(APPNAME)/queue
@ mkdir -p $(TESTDIR)/var/spool/$(APPNAME)/queue
data-$@/* \
$(TESTDIR)/var/spool/$(APPNAME)/queue
@ bin/sorter \
+ -f \
-d 2 \
-c ./conf/mailleur.conf.dvl \
-r $(TESTDIR)
-c ./conf/feeder.conf.dvl \
$(TESTIP) \
$(TESTPORT) \
- ./$(DATATST)/feed00.tst
+ ./$(DATATST)/feed01.tst
@ rm -fr ./data-sorter/*
@ cp -a \
$(TESTDIR)/var/spool/$(APPNAME)/queue/* \
-d 3 \
$(TESTPROT):$(TESTIP):$(TESTPORT):
-onercvr : debug
- @ echo "starting $@"
+dorcvr : debug
@ bin/emlrcvr \
- -f \
- $(EMLPAR)
+ $(EMLPAR)$(TESTITER)
-emlrcvr : prepare #starting email receiver
+emlrcvr : #starting email receiver
@ echo
@ echo "--------------"
@ echo "starting $@"
../lib/geseml.h \
../lib/subrou.h
+sender.o: sender.c \
+ ../lib/lvleml.h \
+ ../lib/geseml.h \
+ ../lib/unieml.h \
+ ../lib/unipar.h \
+ ../lib/unisig.h \
+ ../lib/subrou.h
+
toremake: Makefile $(LIBAI)
touch toremake
- rm -f $(EXE) *.o
#include "unipar.h"
#include "unisig.h"
#include "geseml.h"
+#include "lvleml.h"
/*
\f
#define OPEP "sender.c:dispatcher,"
_Bool status;
-status=false;
+status=true;
if (tra!=(TRATYP **)0) {
- time_t isnow;
- int count;
- TRATYP **ptr;
-
- isnow=time((time_t *)0);
- ptr=tra;
- count=0;
- status=true;
- while (*ptr!=(TRATYP *)0) {
- count++;
- if (((*ptr)->date+(*ptr)->delay)<=isnow) {
- (void) eml_add_delay(isnow,*ptr);
- (void) rou_alert(0,"%s rcpt email <%s> count='%d' sessid=<%s>",
- OPEP,(*ptr)->rcptto,count,(*ptr)->sessid);
- switch ((*ptr)->code) {
- case 'L' : //local delivery
- (*ptr)->code='C'; //delivery done 'C'ompleted
- if (eml_store_email(*ptr)==false) {
- (*ptr)->code='L'; //delivery done 'D'elayed
- (void) rou_alert(0,"%s Unable to deliver email <%s> to <%s>",
- OPEP,(*ptr)->sessid,(*ptr)->rcptto);
- }
- break;
- case 'R' : //remote delivery
-/*
- char temps[40];
-
- (void) strftime(temps,sizeof(temps),"%H:%M:%S",localtime(&isnow));
- //JMPDBG set as the remote email was not succesful
- (void) rou_alert(0,"%s JMPDBG at '%s', Unable to deliver email <%s> to <%s>",
- OPEP,temps,(*ptr)->sessid,(*ptr)->rcptto);
-*/
- break;
- default :
- (void) rou_alert(0,"%s unexpected code '%c'",OPEP,(*ptr)->code);
- status=false;
- break;
- }
- }
- ptr++;
+ switch ((*tra)->code) {
+ case 'L' : //local delivery
+ (void) eml_local_email(tra);
+ break;
+ case 'R' : //Remote delivery
+ (void) eml_remote_email(tra);
+ break;
+ default :
+ (void) rou_alert(0,"%s unexpected code '%c'",OPEP,(*tra)->code);
+ status=false;
+ break;
}
}
return status;
}
break;
case 5 : //updating transfile
- (void) eml_dumptra(qfile,tra);
+ (void) eml_dump_list_tra(qfile,tra);
break;
case 6 : //closing file
qfile=eml_closeqfile(qfile);
#end of /etc/host addon
#====================================================
C:COMMENT STOP
-T:Sending a very Simple Email with local delivery
+T:(feed00) Sending a very Simple Email with local delivery
R:220 mailleur.example.com ESMTP (cleartext) emlrcvr...
#====================================================
S:HELO example.com
-#very simple test to feed SMTP server
#====================================================
-T:Testing if MX is found
+T:(feed01) Sending a a simple mail to remote server
R:220 mailleur.example.com ESMTP (cleartext) emlrcvr...
#====================================================
S:HELO example.com
#R:250-mailleur.example.com, link (cleartext) ready, your IP/FQDN=[127.127.0.2/feed2.example.com]
R:250-mailleur.example.com, link (cleartext) ready,...
+C:GOTLS
+R:250 Link now encryp...
S:MAIL FROM: <postmaster@example.com>
R:250 2.1.3 postmaster@example.com.. sender ok
-S:RCPT TO: <dom1user1@subdom0.example.com>
-R:563 5.6.3 No valid MX found for recipient domain name (rcpt=subdom0.example.com)
S:RCPT TO: <dom1user1@subdom1.example.com>
R:250 2.6.4 Address accepted
+#-------------------------------------------------------------------------
+#-sending data
+C:DATA
+D:Subject: Very Simple email contents
+D:From: Maitre Post <postmaster@example.com>
+D:To: Remote person <dom1user1@subdom1.example.com>
+C:T
+D:
+D:FIRST Line
+D:SECOND Line
+D:LAST Line
+D:.
+D:this is a line with a dot
+D:
+D:.
+D:end
+D:ligne court|
+C:.
+#-------------------------------------------------------------------------
+R:250 3.5.3 Message accepted for delivery
S:QUIT
R:221 2.0.0 Bye, closing connection...
-#-------------------------------------------------------------------------
--- /dev/null
+#very simple test to feed SMTP server
+#====================================================
+T:Testing if MX is found
+R:220 mailleur.example.com ESMTP (cleartext) emlrcvr...
+#====================================================
+S:HELO example.com
+#R:250-mailleur.example.com, link (cleartext) ready, your IP/FQDN=[127.127.0.2/feed2.example.com]
+R:250-mailleur.example.com, link (cleartext) ready,...
+S:MAIL FROM: <postmaster@example.com>
+R:250 2.1.3 postmaster@example.com.. sender ok
+S:RCPT TO: <dom1user1@subdom0.example.com>
+R:563 5.6.3 No valid MX found for recipient domain name (rcpt=subdom0.example.com)
+S:RCPT TO: <dom1user1@subdom1.example.com>
+R:250 2.6.4 Address accepted
+S:QUIT
+R:221 2.0.0 Bye, closing connection...
+#-------------------------------------------------------------------------
subafn.h subafn.c
lvleml.h: \
- gestcp.h
+ devsoc.h devsql.h \
+ geseml.h gestcp.h
gestcp.h: \
subrou.h \
phase=0;
proceed=true;
while (proceed==true) {
- switch (phase) {
+ switch (phase) {
case 0 : //Firsy Check if we have data
if (trans==(TRATYP *)0) {
(void) rou_alert(0,"%s trans is NULL (Bug?)",OPEP);
*/
/********************************************************/
/* */
+/* Procedure to display/debug ONE TRATYP record */
+/* content */
+/* */
+/********************************************************/
+PUBLIC _Bool eml_dump_one_tra(FILE *qfile,TRATYP *tra)
+
+{
+_Bool status;
+
+status=false;
+if (tra!=(TRATYP *)0) {
+ char temps[50];
+ char line[300];
+
+ status=true;
+ (void) strftime(temps,sizeof(temps),"#%Y-%m-%d %H:%M:%S",
+ localtime(&(tra->date)));
+ (void) snprintf(line,sizeof(line),"%c\t%lu\t%04u\t%s\t%s\t%s",
+ tra->code,
+ tra->date,
+ tra->delay,
+ tra->sessid,
+ tra->mailfrom,
+ tra->rcptto
+ );
+ if (qfile==(FILE *)0) {
+ (void) rou_alert(0,"TRA=<%s>",line);
+ }
+ else {
+ (void) fprintf(qfile,"%s\n",temps);
+ (void) fprintf(qfile,"%s\n",line);
+ }
+ }
+return status;
+}
+/*
+\f
+*/
+/********************************************************/
+/* */
/* Procedure to display/debug TRATYP record content*/
/* */
/********************************************************/
-PUBLIC _Bool eml_dumptra(FILE *qfile,TRATYP **tra)
+PUBLIC _Bool eml_dump_list_tra(FILE *qfile,TRATYP **tra)
{
-#define OPEP "geseml.c:eml_dumptra,"
+#define OPEP "geseml.c:eml_dump_list_tra,"
_Bool action;
"originator\t\trecipient\n");
}
while (*tra!=(TRATYP *)0) {
- char temps[50];
- char line[300];
-
- (void) strftime(temps,sizeof(temps),"#%Y-%m-%d %H:%M:%S",
- localtime(&((*tra)->date)));
- (void) snprintf(line,sizeof(line),"%c\t%lu\t%04u\t%s\t%s\t%s",
- (*tra)->code,
- (*tra)->date,
- (*tra)->delay,
- (*tra)->sessid,
- (*tra)->mailfrom,
- (*tra)->rcptto
- );
- if (((*tra)->date+(*tra)->delay)<=isnow) {
- time_t bigre;
- char timer[50];
- char strnow[50];
-
- (void) strftime(strnow,sizeof(strnow),"#%Y-%m-%d %H:%M:%S",
- localtime(&isnow));
- (void) strftime(timer,sizeof(timer),"#%Y-%m-%d %H:%M:%S",
- localtime(&((*tra)->date)));
- (void) rou_alert(0,"%s JMPDBG date=<%s> delay='%04d'",
- OPEP,timer,(*tra)->delay);
- bigre=(*tra)->date+(*tra)->delay;
- (void) strftime(timer,sizeof(temps),"#%Y-%m-%d %H:%M:%S",
- localtime(&bigre));
- (void) rou_alert(0,"%s JMPDBG timer=<%s> iwnow=<%s>",OPEP,timer,strnow);
- (void) rou_alert(0,"%s JMPDBG action=true",OPEP);
+ (void) eml_dump_one_tra(qfile,*tra);
+ if (((*tra)->date+(*tra)->delay)<=isnow)
action=true;
- }
- if (qfile==(FILE *)0) {
- (void) rou_alert(0,"TRA=<%s>",line);
- }
- else {
- (void) fprintf(qfile,"%s\n",temps);
- (void) fprintf(qfile,"%s\n",line);
- }
tra++;
}
}
break;
case 1 : //dumping TRANS data to file
(void) eml_sort_list((*ptr)->todo);
- if ((action=eml_dumptra(qfile,(*ptr)->todo))==true) {
+ if ((action=eml_dump_list_tra(qfile,(*ptr)->todo))==true) {
ext=EXTODO;
}
break;
phase=999; //Trouble trouble
break;
case 1 : //dumping TRANS data to file
- (void) eml_dumptra(qfile,next);
+ (void) eml_dump_list_tra(qfile,next);
break;
case 2 : //Closing file
(void) eml_closeqfile(qfile);
char *rcptto; //EMail Recipient
}TRATYP;
-//procedure to dump a transfert record (debug purpose)
-extern _Bool eml_dumptra(FILE *out,TRATYP **tra);
+//procedure to dump a list of transfert record
+extern _Bool eml_dump_one_tra(FILE *out,TRATYP *tra);
+
+//procedure to dump a list of transfert record
+extern _Bool eml_dump_list_tra(FILE *out,TRATYP **tra);
//procedure to fee memory used by a TRATYP structure
extern TRATYP *eml_freetra(TRATYP *tra);
tralist=(TRATYP **)rou_addlist((void **)tralist,(void *)tra);
ptr++;
}
- (void) eml_dumptra(qfile,tralist);
+ (void) eml_dump_list_tra(qfile,tralist);
tralist=(TRATYP **)rou_freelist((void **)tralist,(genfree_t)eml_freetra);
}
return status;
#undef OPEP
}
+/*
+^L
+*/
+/********************************************************/
+/* */
+/* Procedure to store local email (MX local) within*/
+/* the serveur right directory. */
+/* */
+/********************************************************/
+PUBLIC void eml_local_email(TRATYP **tra)
+
+{
+#define OPEP "lvleml.c:eml_local_email,"
+
+time_t isnow;
+
+isnow=time((time_t *)0);
+while (*tra!=(TRATYP *)0) {
+ if (((*tra)->date+(*tra)->delay)>isnow)
+ continue;
+ (void) eml_add_delay(isnow,*tra);
+ switch ((*tra)->code) {
+ case 'L' : //local email (MX is local)
+ (*tra)->code='C';
+ if (eml_store_email(*tra)==false) {
+ (*tra)->code='L'; //Will try to deliver later one
+ (void) rou_alert(0,"%s Unable to deliver local email <%s> to <%s>",
+ OPEP,(*tra)->sessid,(*tra)->rcptto);
+ }
+ break;
+ default : //Unexpected local? email??
+ (void) rou_alert(0,"%s Directive is not! local email (Bug?)",OPEP);
+ (void) rou_alert(0,"%s TRA=<%cs %lu %04u %s %s %s",OPEP,
+ (*tra)->code,
+ (*tra)->date,
+ (*tra)->delay,
+ (*tra)->sessid,
+ (*tra)->mailfrom,
+ (*tra)->rcptto);
+ break;
+ }
+ tra++;
+ }
+#undef OPEP
+}
+/*
+^L
+*/
+/********************************************************/
+/* */
+/* Procedure to send email to remote recipient */
+/* */
+/********************************************************/
+PUBLIC void eml_remote_email(TRATYP **tra)
+
+{
+#define OPEP "lvleml.c:eml_remote_email,"
+
+(void) rou_alert(0,"%s JMPDBG",OPEP);
+#undef OPEP
+}
#include "devsoc.h"
#include "devsql.h"
#include "gestcp.h"
+#include "geseml.h"
typedef struct {
SOCPTR *socptr; //established contact socket context
//generate trans file contents
extern _Bool eml_mktransfile(CONTYP *contact,FILE *qfile);
+
+//store local email within domain proper directory
+extern void eml_local_email(TRATYP **tra);
+
+//sending email to remote recipents
+extern void eml_remote_email(TRATYP **tra);
+
#endif