changeset 103:bf4390ecc30b

Also dump MAIL FROM:, RCPT TO: and Reply To: variables in the case of an error. Make it known by the filename that's it's a moderaterequest. That way it's a lot easier for the maintenance process to know how to react.
author mmj
date Sun, 23 May 2004 00:36:20 +1000
parents 713e9d076c26
children 61878b2bf9f4
files src/mlmmj-process.c src/mlmmj-send.c
diffstat 2 files changed, 27 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/mlmmj-process.c	Sat May 22 23:57:12 2004 +1000
+++ b/src/mlmmj-process.c	Sun May 23 00:36:20 2004 +1000
@@ -50,7 +50,8 @@
 		free(moderatorfilename);
 		exit(EXIT_FAILURE);
 	}
-	queuefilename = concatstr(3, listdir, "/queue/", randomstr);
+	queuefilename = concatstr(4, listdir, "/queue/", randomstr,
+				  ".moderaterequest");
 	printf("%s\n", queuefilename);
 	
 	if((queuefile = fopen(queuefilename, "w")) == NULL) {
--- a/src/mlmmj-send.c	Sat May 22 23:57:12 2004 +1000
+++ b/src/mlmmj-send.c	Sun May 23 00:36:20 2004 +1000
@@ -289,10 +289,10 @@
 {
 	size_t len = 0;
 	int sockfd = 0, opt, mindex;
-	FILE *subfile = NULL, *mailfile = NULL;
+	FILE *subfile = NULL, *mailfile = NULL, *tmpfile;
 	char *listaddr, *mailfilename = NULL, *subfilename = NULL;
 	char *replyto = NULL, *bounceaddr = NULL, *to_addr = NULL;
-	char *relayhost = NULL, *archivefilename = NULL;
+	char *relayhost = NULL, *archivefilename = NULL, *tmpstr;
 	char *listctrl = NULL, *subddirname = NULL, *listdir = NULL;
 	int deletewhensent = 1, *newsockfd, sendres;
 	DIR *subddir;
@@ -407,9 +407,30 @@
 		initsmtp(&sockfd, relayhost);
 		sendres = send_mail(sockfd, bounceaddr, to_addr,
 				replyto, mailfile);
-		if(sendres) /* error, so keep it in the queue */
+		endsmtp(&sockfd);
+		if(sendres) {
+			/* error, so keep it in the queue */
 			deletewhensent = 0;
-		endsmtp(&sockfd);
+			/* dump date we want when resending */
+			tmpstr = concatstr(2, mailfilename, ".mailfrom");
+			tmpfile = fopen(tmpstr, "w");
+			free(tmpstr);
+			fputs(bounceaddr, tmpfile);
+			fclose(tmpfile);
+			tmpstr = concatstr(2, mailfilename, ".rcptto");
+			tmpfile = fopen(tmpstr, "w");
+			free(tmpstr);
+			fputs(to_addr, tmpfile);
+			fclose(tmpfile);
+			if(replyto) {
+				tmpstr = concatstr(2, mailfilename,
+						      ".replyto");
+				tmpfile = fopen(tmpstr, "w");
+				free(tmpstr);
+				fputs(replyto, tmpfile);
+				fclose(tmpfile);
+			}
+		}
 		break;
 	case '2': /* Moderators */
 		initsmtp(&sockfd, relayhost);