#include <uuid/uuid.h>
#include "subrou.h"
+#include "unidns.h"
#include "unieml.h"
#include "unipar.h"
+#include "unitls.h"
#include "geseml.h"
//dovecot local storage directory
}
break;
case 'W' : //need to send a warning
- (void) rou_alert(0,"%s JMPDBG need to do warning <%s>",OPEP,(*ptr)->sessid);
+ (void) eml_do_warning(*ptr);
break;
default :
break;
}
return result;
}
+/*
+^L
+*/
+/********************************************************/
+/* */
+/* Procedure to build a waring/reply about an */
+/* unsuccessfull email sending. The Email is sent */
+/* back to the originator. */
+/* */
+/********************************************************/
+PUBLIC _Bool eml_do_warning(TRATYP *tra)
+
+{
+#define OPEP "geseml.c:eml_do_warning,"
+
+_Bool done;
+int phase;
+_Bool proceed;
+
+done=false;
+phase=0;
+proceed=true;
+while (proceed==true) {
+ (void) rou_alert(0,"JMPDBG %s phase='%d'",OPEP,phase);
+ switch (phase) {
+ case 0 : //check if email is FROM local or remote
+ char *domain;
+ int status;
+
+ domain=strchr(tra->mailfrom,'@');
+ status=dns_is_domain_local(domain,tls_get_bind_afn());
+ switch (status) {
+ case dns_local :
+ tra->code='L';
+ break;
+ case dns_remote :
+ tra->code='R';
+ break;
+ case dns_nomx : //Should NEVER ever occur
+ (void) rou_alert(0,"%s Unable to find MX for domain<%s> (bug?)",
+ OPEP,status,domain);
+ phase=999;
+ break;
+ default :
+ (void) rou_alert(0,"%s Unexpected status='%d' for domain<%s> (bug?)",
+ OPEP,status,domain);
+ phase=999;
+ break;
+ }
+ break;
+ case 1 : //reversing originator/recipient
+ char dname[60];
+ char orig[100];
+
+ (void) memset(&dname,'\000',sizeof(dname));
+ (void) getdomainname(dname,sizeof(dname));
+ (void) snprintf(orig,sizeof(orig),"%s@%s","noreply",dname);
+ tra->rcptto=rou_freestr(tra->rcptto);
+ tra->rcptto=tra->mailfrom;
+ tra->mailfrom=strdup(orig);
+ done=true;
+ break;
+ default : //SAFE Guard
+ proceed=false;
+ break;
+ }
+ phase++;
+ }
+return done;
+
+#undef OPEP
+}