./$(DATATST)/extfeed00.tst
onefeed : debug
- bin/feeder \
+ @ bin/feeder \
-f \
-d2 \
-c ./conf/feeder.conf.dvl \
chkspf \
emlrcvr \
feeder \
+ sender \
sorter \
SRC= \
chkspf.c \
emlrcvr.c \
freeder.c \
+ sender.c \
sorter.c \
#--------------------------------------------------------------------
feeder : toremake feeder.o
@ $(LD) $(LDFLAGS) -o ../bin/$@ $@.o $(LIBS)
+sender : toremake sender.o
+ @ $(LD) $(LDFLAGS) -o ../bin/$@ $@.o $(LIBS)
+
sorter : toremake sorter.o
@ $(LD) $(LDFLAGS) -o ../bin/$@ $@.o $(LIBS)
--- /dev/null
+// vim: smarttab tabstop=8 shiftwidth=2 expandtab
+/********************************************************/
+/* */
+/* SMTP protocol sender. */
+/* Take a a file with todo email to send. */
+/* */
+/* Format is: */
+/* sender [trans1 trabs2...] */
+/* */
+/********************************************************/
+#include <dirent.h>
+#include <stdlib.h>
+#include <syslog.h>
+#include <unistd.h>
+
+#include "subrou.h"
+#include "unieml.h"
+#include "unipar.h"
+#include "unisig.h"
+#include "geseml.h"
+
+#define SENDER "sender" //application name
+
+/********************************************************/
+/* */
+/* procedure to scan all files */
+/* */
+/********************************************************/
+static _Bool scantrans()
+
+{
+#define OPEP "sorter.c:scantrans,"
+
+_Bool status;
+char **fname;
+TRATYP **trans;
+int phase;
+_Bool proceed;
+
+status=false;
+fname=(char **)0;
+trans=(TRATYP **)0;
+phase=0;
+proceed=true;
+while (proceed==true) {
+ switch (phase) {
+ case 0 : //Getting the list of file
+ fname=eml_getqfilelist(fname,".trans");
+ if (fname==(char **)0)
+ phase=999; //Nothing to do
+ break;
+ case 1 : //Building the "trans" list
+ if (fname!=(char **)0) { //walways
+ char **ptr;
+
+ ptr=fname;
+ while (*ptr!=(char *)0) {
+ FILE *qfile;
+
+ (void) rou_alert(0,"%s fame=<%s>",OPEP,*ptr);
+ if ((qfile=eml_openqfile(*ptr))!=(FILE *)0) {
+ trans=eml_scanqfile(trans,qfile);
+ (void) eml_closeqfile(qfile);
+ (void) eml_deleteqfile(*ptr);
+ }
+ ptr++;
+ }
+ fname=(char **)rou_freelist((void *)fname,(freehandler_t)rou_freestr);
+ }
+ break;
+ case 2 : //scanning translit
+ if (trans!=(TRATYP **)0) {
+ TRATYP **ptr;
+
+ ptr=trans;
+ (void) eml_todoqfile(ptr);
+ trans=(TRATYP **)rou_freelist((void **)trans,(freehandler_t)eml_freetra);
+ status=true;
+ }
+ break;
+ default : //SAFE Guard
+ proceed=false;
+ break;
+ }
+ phase++;
+ }
+return status;
+#undef OPEP
+}
+/*
+\f
+*/
+/********************************************************/
+/* */
+/* Main routine */
+/* Start a channel to a remote ip.port */
+/* read file and transmit contecnts to */
+/* remote SMTP server. */
+/* */
+/********************************************************/
+int main(int argc,char *argv[])
+
+{
+int status;
+ARGTYP *params;
+int phase;
+_Bool proceed;
+
+status=0;
+params=(ARGTYP *)0;
+foreground=true;
+phase=0;
+proceed=true;
+while (proceed==true) {
+ //(void) fprintf(stdout,"JMPDBG main phase='%d'\n",phase);
+ switch (phase) {
+ case 0 : //checking parameters
+ if ((params=par_getparams(argc,argv,"c:d:fhi:r:v"))==(ARGTYP *)0) {
+ proceed=false; //no need to go further
+ }
+ break;
+ case 1 : //Preparing scan
+ (void) rou_modesubrou(true);
+ (void) sig_modeunisig(true);
+ (void) rou_setappname(SENDER);
+ (void) rou_loadconfig(config,true);
+ (void) openlog(appname,LOG_NDELAY|LOG_PID,LOG_DAEMON);
+ (void) closelog();
+ break;
+ case 2 : //Scanning all file
+ phase--; //Looping on same phase
+ if ((hangup==true)||(reload==true))
+ phase=999; //Process
+ if (scantrans()==false)
+ phase=999;
+ (void) sleep(5);
+ break;
+ default : //end of task
+ params=par_freeparams(params);
+ (void) rou_loadconfig(config,false);
+ (void) sig_modeunisig(false);
+ (void) rou_modesubrou(false);
+ proceed=false;
+ break;
+ }
+ phase++;
+ }
+(void) exit(status);
+}
// vim: smarttab tabstop=8 shiftwidth=2 expandtab
/********************************************************/
/* */
-/* SMTP protocol feeder. */
-/* Used to transmit data to remote SMTP server. */
+/* SMTP protocol sender */
+/* Used to take the trans directive and generate */
+/* a todo list a email to be send. */
/* */
-/* Format is: */
-/* feeder ip port [file1 file2...] */
/* */
/********************************************************/
#include <dirent.h>
#====================================================
T:Very Simple email sending
R:220 mailleur.example.com ESMTP (cleartext) emlrcvr...
-C:ORGN 127.127.0.2
-R:220 mailleur.example.com ESMTP (cleartext) emlrcvr...
-#C:WAIT 100
#====================================================
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>
+S:563 0.0.0 No valid MX found for recipient domain name (subdom0.example.com)
S:RCPT TO: <dom1user1@subdom1.example.com>
-R:250 2.6.4 Address accepted
-S:RCPT TO: <dom2user1@subdom2.example.com>
-R:250 2.6.4 Address accepted
-S:RCPT TO: <dom2user2@subdom2.example.com>
-R:250 2.6.4 Address accepted
-#-------------------------------------------------------------------------
-#-sending data
-C:DATA
-Subject: Very Simple email contents
-
-FIRST Line
-SECOND Line
-LAST Line
-
-.
-#-------------------------------------------------------------------------
R:250 3.5.3 Message accepted for delivery
S:QUIT
R:221 2.0.0 Bye, closing connection...
#-------------------------------------------------------------------------
-#prepare next test
-#waiting 1 sec
-C:WAIT 1
-#-restarting link
-C:RESTART
-R:220 mailleur.example.com ESMTP (cleartext) emlrcvr...
-S:MAIL FROM: <webmaster@example.com>
-R:250 2.1.3 webmaster@example.com.. sender ok
-S:RCPT TO: <dom1user1@subdom1.example.com>
-R:250 2.6.4 Address accepted
-S:RCPT TO: <dom1user2@subdom1.example.com>
-R:250 2.6.4 Address accepted
-S:RCPT TO: <dom2user1@subdom2.example.com>
-R:250 2.6.4 Address accepted
-S:RCPT TO: <dom2user2@subdom2.example.com>
-R:250 2.6.4 Address accepted
-#-------------------------------------------------------------------------
-#-sending data
-C:DATA
-Subject: Second email contents
-
-SECOND FIRST Line
-SECOND SECOND Line
-SECOND LAST Line
-
-.
-#-------------------------------------------------------------------------
-R:250 3.5.3 Message accepted for delivery
-S:QUIT
-#-------------------------------------------------------------------------
-#prepare next test
-#waiting 1 sec
-C:WAIT 1
-#-restarting link
-C:RESTART
-R:220 mailleur.example.com ESMTP (cleartext) emlrcvr...
-S:MAIL FROM: <noreply@example.com>
-R:250 2.1.3 noreply@example.com.. sender ok
-S:RCPT TO: <dom1user1@subdom1.example.com>
-R:250 2.6.4 Address accepted
-S:RCPT TO: <dom1user2@subdom1.example.com>
-R:250 2.6.4 Address accepted
-S:RCPT TO: <dom2user1@subdom2.example.com>
-R:250 2.6.4 Address accepted
-S:RCPT TO: <dom2user2@subdom2.example.com>
-R:250 2.6.4 Address accepted
-#-------------------------------------------------------------------------
-#-sending data
-C:DATA
-Subject: Third email contents
-
-THIRD FIRST Line
-THIRD SECOND Line
-THIRD LAST Line
-
-.
-#-------------------------------------------------------------------------
-R:250 3.5.3 Message accepted for delivery
-S:QUIT
--- /dev/null
+#very simple test to feed SMTP server
+#====================================================
+T:Very Simple email sending
+R:220 mailleur.example.com ESMTP (cleartext) emlrcvr...
+C:ORGN 127.127.0.2
+R:220 mailleur.example.com ESMTP (cleartext) emlrcvr...
+#C:WAIT 100
+#====================================================
+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@subdom1.example.com>
+R:250 2.6.4 Address accepted
+S:RCPT TO: <dom2user1@subdom2.example.com>
+R:250 2.6.4 Address accepted
+S:RCPT TO: <dom2user2@subdom2.example.com>
+R:250 2.6.4 Address accepted
+#-------------------------------------------------------------------------
+#-sending data
+C:DATA
+Subject: Very Simple email contents
+
+FIRST Line
+SECOND Line
+LAST Line
+
+.
+#-------------------------------------------------------------------------
+R:250 3.5.3 Message accepted for delivery
+S:QUIT
+R:221 2.0.0 Bye, closing connection...
+#-------------------------------------------------------------------------
+#prepare next test
+#waiting 1 sec
+C:WAIT 1
+#-restarting link
+C:RESTART
+R:220 mailleur.example.com ESMTP (cleartext) emlrcvr...
+S:MAIL FROM: <webmaster@example.com>
+R:250 2.1.3 webmaster@example.com.. sender ok
+S:RCPT TO: <dom1user1@subdom1.example.com>
+R:250 2.6.4 Address accepted
+S:RCPT TO: <dom1user2@subdom1.example.com>
+R:250 2.6.4 Address accepted
+S:RCPT TO: <dom2user1@subdom2.example.com>
+R:250 2.6.4 Address accepted
+S:RCPT TO: <dom2user2@subdom2.example.com>
+R:250 2.6.4 Address accepted
+#-------------------------------------------------------------------------
+#-sending data
+C:DATA
+Subject: Second email contents
+
+SECOND FIRST Line
+SECOND SECOND Line
+SECOND LAST Line
+
+.
+#-------------------------------------------------------------------------
+R:250 3.5.3 Message accepted for delivery
+S:QUIT
+#-------------------------------------------------------------------------
+#prepare next test
+#waiting 1 sec
+C:WAIT 1
+#-restarting link
+C:RESTART
+R:220 mailleur.example.com ESMTP (cleartext) emlrcvr...
+S:MAIL FROM: <noreply@example.com>
+R:250 2.1.3 noreply@example.com.. sender ok
+S:RCPT TO: <dom1user1@subdom1.example.com>
+R:250 2.6.4 Address accepted
+S:RCPT TO: <dom1user2@subdom1.example.com>
+R:250 2.6.4 Address accepted
+S:RCPT TO: <dom2user1@subdom2.example.com>
+R:250 2.6.4 Address accepted
+S:RCPT TO: <dom2user2@subdom2.example.com>
+R:250 2.6.4 Address accepted
+#-------------------------------------------------------------------------
+#-sending data
+C:DATA
+Subject: Third email contents
+
+THIRD FIRST Line
+THIRD SECOND Line
+THIRD LAST Line
+
+.
+#-------------------------------------------------------------------------
+R:250 3.5.3 Message accepted for delivery
+S:QUIT
#very simple test to feed SMTP server
#====================================================
-T:Very Simple email sending
+T:Testing if MX is found
R:220 mailleur.example.com ESMTP (cleartext) emlrcvr...
-C:ORGN 127.127.0.2
-R:220 mailleur.example.com ESMTP (cleartext) emlrcvr...
-#C:WAIT 100
#====================================================
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: <postmaster@example.com>
-R:250 2.6.4 Address accepted
-S:RCPT TO: <user1@sub1.example.com>
-R:250 2.6.4 Address accepted
-S:RCPT TO: <user2@sub2.example.com>
+S:RCPT TO: <dom1user1@subdom0.example.com>
+R:563 0.0.0 No valid MX found for recipient domain name (subdom0.example.com)
+S:RCPT TO: <dom1user1@subdom1.example.com>
R:250 2.6.4 Address accepted
-#-------------------------------------------------------------------------
-#-sending data
-C:DATA
-Subject: Very Simple email contents
-
-FIRST Line
-SECOND Line
-LAST Line
-
-.
-#-------------------------------------------------------------------------
-R:250 3.5.3 Message accepted for delivery
S:QUIT
R:221 2.0.0 Bye, closing connection...
#-------------------------------------------------------------------------
-#prepare next test
-#waiting 1 sec
-C:WAIT 1
-#-restarting link
-C:RESTART
-R:220 mailleur.example.com ESMTP (cleartext) emlrcvr...
-S:MAIL FROM: <webmaster@example.com>
-R:250 2.1.3 webmaster@example.com.. sender ok
-S:RCPT TO: <postmaster@example.com>
-R:250 2.6.4 Address accepted
-S:RCPT TO: <user1@sub1.example.com>
-R:250 2.6.4 Address accepted
-S:RCPT TO: <user2@sub2.example.com>
-R:250 2.6.4 Address accepted
-#-------------------------------------------------------------------------
-#-sending data
-C:DATA
-Subject: Second email contents
-
-SECOND FIRST Line
-SECOND SECOND Line
-SECOND LAST Line
-
-.
-#-------------------------------------------------------------------------
-R:250 3.5.3 Message accepted for delivery
-S:QUIT
-#-------------------------------------------------------------------------
-#prepare next test
-#waiting 1 sec
-C:WAIT 1
-#-restarting link
-C:RESTART
-R:220 mailleur.example.com ESMTP (cleartext) emlrcvr...
-S:MAIL FROM: <noreply@example.com>
-R:250 2.1.3 noreply@example.com.. sender ok
-S:RCPT TO: <postmaster@example.com>
-R:250 2.6.4 Address accepted
-S:RCPT TO: <user1@sub1.example.com>
-R:250 2.6.4 Address accepted
-S:RCPT TO: <user2@sub2.example.com>
-R:250 2.6.4 Address accepted
-#-------------------------------------------------------------------------
-#-sending data
-C:DATA
-Subject: Third email contents
-
-THIRD FIRST Line
-THIRD SECOND Line
-THIRD LAST Line
-
-.
-#-------------------------------------------------------------------------
-R:250 3.5.3 Message accepted for delivery
-S:QUIT
--- /dev/null
+R,1747506314,0 00317-20250517142513-0859-0000 webmaster@example.com dom1user1@subdom1.example.com
+R,1747506314,0 00317-20250517142513-0859-0000 webmaster@example.com dom1user2@subdom1.example.com
+R,1747506312,0 00313-20250517142512-0184-0000 postmaster@example.com dom1user1@subdom1.example.com
+R,1747506315,0 00326-20250517142515-0493-0000 noreply@example.com dom1user1@subdom1.example.com
+R,1747506315,0 00326-20250517142515-0493-0000 noreply@example.com dom1user2@subdom1.example.com
--- /dev/null
+R,1747506314,0 00317-20250517142513-0859-0000 webmaster@example.com dom2user1@subdom2.example.com
+R,1747506314,0 00317-20250517142513-0859-0000 webmaster@example.com dom2user2@subdom2.example.com
+R,1747506312,0 00313-20250517142512-0184-0000 postmaster@example.com dom2user1@subdom2.example.com
+R,1747506312,0 00313-20250517142512-0184-0000 postmaster@example.com dom2user2@subdom2.example.com
+R,1747506315,0 00326-20250517142515-0493-0000 noreply@example.com dom2user1@subdom2.example.com
+R,1747506315,0 00326-20250517142515-0493-0000 noreply@example.com dom2user2@subdom2.example.com