#very simple test to feed SMTP server
#====================================================
-T:Testing if MX is found
+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>
-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: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
if (contact!=(CONTYP *)0) {
contact->sqlptr=sql_closesql(contact->sqlptr);
contact->logptr=log_closelog(contact->logptr);
- contact->rcptto=(char **)rou_freelist((void **)contact->rcptto,
- (freehandler_t)rou_freestr);
+ contact->recipients=eml_freerecipients(contact->recipients);
contact->mailfrom=rou_freestr(contact->mailfrom);
contact->cursesid=rou_freestr(contact->cursesid);
contact->mainsesid=rou_freestr(contact->mainsesid);
}
break;
case 4 : //Storing rcpt to
- if (eml_addemail(&(contact->rcptto),rcptto)==false) {
+ if (eml_addrecipient(&(contact->recipients),'L',rcptto)==false) {
detail="duplicate recipients will be consolidated";
}
break;
_Bool status;
-if ((contact!=(CONTYP *)0)&&(contact->rcptto!=(char **)0)) {
- char **ptr;
-
- ptr=contact->rcptto;
- while (*ptr!=(char *)0) {
- time_t isnow;
-
- status=true;
- isnow=time((time_t *)0);
- if (fprintf(qfile,"%c %ld %d %s %s %s\n",
- 'R',isnow,0,contact->cursesid,contact->mailfrom,*ptr)<0) {
+status=true;
+if ((contact!=(CONTYP *)0)&&(contact->recipients!=(RCPTYP **)0)) {
+ RCPTYP **ptr;
+ time_t isnow;
+
+ ptr=contact->recipients;
+ isnow=time((time_t *)0);
+ while (*ptr!=(RCPTYP *)0) {
+ char data[300];
+
+ (void) snprintf(data,sizeof(data),"%c %ld %d %s %s %s",
+ (*ptr)->code,
+ isnow,
+ 0,
+ contact->cursesid,
+ contact->mailfrom,
+ (*ptr)->rcpt);
+ if (fprintf(qfile,"%s\n",data)<0) {
(void) rou_alert(0,"%s Unable to write transfile (error=<%s>)",
- OPEP,strerror(errno));
+ OPEP,strerror(errno));
status=false;
}
ptr++;
#include "gestcp.h"
typedef struct {
- SOCPTR *socptr; //established contact socket context
- SQLPTR *sqlptr; //established contact database access
- char *fqdn; //fully qualified domain from peer
- char *locname; //socket local hostname
- char *locserv; //local service port
- char *peerip; //socket remote peer IP
- char *peername; //socket remote peer FQDN
- int numreset; //number of SMTP reset received
- char *mainsesid;//session main ID
- char *cursesid; //current session ID
- char *mailfrom; //current mail from originator
- char **rcptto; //List of mail recipient
- LOGPTR *logptr; //reference to session log
+ SOCPTR *socptr; //established contact socket context
+ SQLPTR *sqlptr; //established contact database access
+ char *fqdn; //fully qualified domain from peer
+ char *locname; //socket local hostname
+ char *locserv; //local service port
+ char *peerip; //socket remote peer IP
+ char *peername; //socket remote peer FQDN
+ int numreset; //number of SMTP reset received
+ char *mainsesid; //session main ID
+ char *cursesid; //current session ID
+ char *mailfrom; //current mail from originator
+ RCPTYP **recipients; //List of email recipient
+ LOGPTR *logptr; //reference to session log
}CONTYP;
}
break;
case 2 : //Requesting MX for domain
- (void) rou_alert(0,"%s JMPDBG domain=<%s>",OPEP,domain);
answer=myquery(domain,C_IN,T_MX,rsp.buf,sizeof(rsp.buf));
if (answer<=0)
phase=999; //Trouble trouble to get MX
*/
/********************************************************/
/* */
+/* Procedure to free memory used by a list of */
+/* recipient. */
+/* */
+/********************************************************/
+PUBLIC RCPTYP **eml_freerecipients(RCPTYP **list)
+
+{
+if (list!=(RCPTYP **)0) {
+ RCPTYP **ptr;
+
+ ptr=list;
+ while (*ptr!=(RCPTYP *)0) {
+ (*ptr)->rcpt=rou_freestr((*ptr)->rcpt);
+ (void) free(*ptr);
+ ptr++;
+ }
+ (void) free(list);
+ list=(RCPTYP **)0;
+ }
+return list;
+}
+/*
+^L
+*/
+/********************************************************/
+/* */
+/* Procedure to store an recipient information */
+/* within the contact list. */
+/* retuurn RCPTYP ** if successful, NULL otherwise.*/
+/* */
+/********************************************************/
+PUBLIC _Bool eml_addrecipient(RCPTYP ***list,char code,char *rcpt)
+
+{
+_Bool todo;
+
+todo=true;
+if (*list!=(RCPTYP **)0) {
+ RCPTYP **ptr;
+
+ ptr=*list;
+ while (*ptr!=(RCPTYP *)0) {
+ if (strcasecmp((*ptr)->rcpt,rcpt)==0) {
+ todo=false;
+ break; //already within list
+ }
+ ptr++;
+ }
+ }
+if (todo==true) {
+ RCPTYP *neu;
+
+ neu=(RCPTYP *)calloc(1,sizeof(RCPTYP));
+ neu->code=code;
+ neu->rcpt=strdup(rcpt);
+ *list=(RCPTYP **)rou_addlist((void **)(*list),neu);
+ }
+return todo;
+}
+/*
+^L
+*/
+/********************************************************/
+/* */
/* Procedure to format and return a dynamicaly */
/* allocated char array filled with uniq session ID*/
/* */
c_unknown //key word unknown
}CODTYP;
+typedef struct { //*definition of recipient
+ char code; //'L' rcipient local, 'R' recipient remote
+ char *rcpt; //recipient email address
+ }RCPTYP;
+
+//procedure to Free a recipient list
+extern RCPTYP **eml_freerecipients(RCPTYP **list);
+
+//procedure to add recipient to a recipient list
+extern _Bool eml_addrecipient(RCPTYP ***list,char code,char *rcpt);
+
//get a session unique id
extern char *eml_getmainsesid();
//procedure to open a specific qfile
extern FILE *eml_openqfile(char *qfilename);
-//procedure to add an email address to a chain
-//of email address
-extern _Bool eml_addemail(char ***emails,char *email);
-
//procedure to check email address format
//of an email address
extern _Bool eml_isemailok(char *email,const char **domain,char **report);