Skip to contentSkip to conversation

PATCH: Not me too

PATCH Ben Schmidt 3 participants 6 messages Jan 25, 2010 – Jan 30, 2010

lore
Share & tools
lore
#0 lore raw

The attached patch adds a 'not me too' feature to mlmmj, where post senders are excluded from the post distribution so people don't get copies of their own mail. A number of people, particularly those who aren't familiar with traditional email mailing lists, prefer this. It applies on top of the tunables patch I emailed earlier (which I neglected to mention applies over 1.2.17).

Some info and design decisions:

I decided a simple boolean tunable would suffice for this, at least in the short term, and quite probably long term, too. For now, people who really want confirmation their mail has arrived on the list can always subscribe a nomail email to post from. I will devote my mind to how this could neatly be extended later if it seems warranted.

Thanks to Franky for getting me started on this. The from address in those low level sending functions is the envelope sender, so based on the list address, not the sender of the mail, though. The sender of the mail is parsed with the other mail headers in mlmmj-process. This means I needed to communicate that information from mlmmj-process to mlmmj-send. Commandline paramaters seemed the way most consistent with the rest of the program, so I added an option.

I also had to decide whether the tunable should be tested in mlmmj-process or mlmmj-send. I opted for mlmmj-process, as that's where most decisions about whether and where to send mail are made, and as a general rule it's best if commandline arguments can override tunables rather than be affected by them. Thus I added an '-o' option to omit a specified address. The alternative is making the option specify an originator address, and testing the tunable in mlmmj-send to see whether or not to omit them from the distribution.

I decided to do an extra pass through the recipients list in main() to do the filtering rather than modify the lower level functions, as the functions are used in numerous locations, but this filtering is only required once, so an interface change doesn't seem warranted, and iterating the recipients shouldn't be too slow, even for large lists.

Comments? Questions?

I have tested it and it works fine for me.

Could this be included in mlmmj?

The patch includes updating the php and perl web admin interfaces' tunables.pl file. Should I be CCing people of that code specifically?

Cheers,

Ben.

TUNABLES +6 -0
diff -ru mlmmj-1.2.17/TUNABLES mlmmj-1.2.17-mod/TUNABLES
@@ -217,3 +217,9 @@
 
    The content of this file is appended to mail sent to the list.
 
+ ��� notmetoo			(boolean)
+
+   If this file is present, mlmmj attempts to exclude the sender of a post
+   from the distribution list for that post so people don't receive copies
+   of their own posts.
+
contrib/web/perl-admin/conf/tunables.pl +6 -0
diff -ru mlmmj-1.2.17/contrib/web/perl-admin/conf/tunables.pl mlmmj-1.2.17-mod/contrib/web/perl-admin/conf/tunables.pl
@@ -205,3 +205,9 @@
 			  "Footer",
 			  "The content of this option is appended to mail sent to the list.");
 
+mlmmj_boolean("notmetoo",
+			  "Not me too",
+			  "If this is set, mlmmj attempts to exclude the sender of a post ".
+			  "from the distribution list for that post so people don't receive copies ".
+			  "of their own posts.");
+
contrib/web/php-admin/conf/tunables.pl +6 -0
diff -ru mlmmj-1.2.17/contrib/web/php-admin/conf/tunables.pl mlmmj-1.2.17-mod/contrib/web/php-admin/conf/tunables.pl
@@ -205,3 +205,9 @@
 			  "Footer",
 			  "The content of this option is appended to mail sent to the list.");
 
+mlmmj_boolean("notmetoo",
+			  "Not me too",
+			  "If this is set, mlmmj attempts to exclude the sender of a post ".
+			  "from the distribution list for that post so people don't receive copies ".
+			  "of their own posts.");
+
man/mlmmj-send.1 +5 -3
diff -ru mlmmj-1.2.17/man/mlmmj-send.1 mlmmj-1.2.17-mod/man/mlmmj-send.1
@@ -1,11 +1,11 @@
-.TH mlmmj-send "1" "September 2004" mlmmj-send
+.TH mlmmj-send "1" "January 2010" mlmmj-send
 .SH NAME
 mlmmj-send \- send mail to a mailinglist or similar
 .SH SYNOPSIS
 .B mlmmj-send
 [\fI-L\fR /path/to/list | \fI-l\fR listctrl] \fI\-m\fR /path/to/mail
-[\fI-a\fR] [\fI-D\fR] [\fI-F\fR] [\fI-h\fR] [\fI-r\fR] [\fI-R\fR] [\fI-s\fR]
-[\fI-T\fR] [\fI-V\fR]
+[\fI-a\fR] [\fI-D\fR] [\fI-F\fR] [\fI-h\fR] [\fI-o\fR] [\fI-r\fR] [\fI-R\fR]
+[\fI-s\fR] [\fI-T\fR] [\fI-V\fR]
 .HP
 \fB\-a\fR: Don't archive the mail
 .HP
@@ -21,6 +21,8 @@
 .HP
 \fB\-m\fR: Full path to mail file
 .HP
+\fB\-o\fR: Address to omit from distribution (normal mail only)
+.HP
 \fB\-r\fR: Relayhost IP address (defaults to 127.0.0.1)
 .HP
 \fB\-R\fR: What to use as Reply-To: header
src/mlmmj-process.c +9 -1
diff -ru mlmmj-1.2.17/src/mlmmj-process.c mlmmj-1.2.17-mod/src/mlmmj-process.c
@@ -336,6 +336,7 @@
 	int maxmailsize = 0;
 	int notoccdenymails = 0, noaccessdenymails = 0, nosubonlydenymails = 0;
 	int nomaxmailsizedenymails = 0;
+	int notmetoo = 0;
 	char *listdir = NULL, *mailfile = NULL, *headerfilename = NULL;
 	char *footerfilename = NULL, *donemailname = NULL;
 	char *randomstr = NULL, *mqueuename;
@@ -946,7 +950,14 @@
 		exit(EXIT_SUCCESS);
 	}
 
-	execlp(mlmmjsend, mlmmjsend,
+	notmetoo = statctrl(listdir, "notmetoo");
+	if (notmetoo)
+		execlp(mlmmjsend, mlmmjsend,
+				"-L", listdir,
+				"-o", fromemails.emaillist[0],
+				"-m", donemailname, (char *)NULL);
+	else
+		execlp(mlmmjsend, mlmmjsend,
 				"-L", listdir,
 				"-m", donemailname, (char *)NULL);
 	log_error(LOG_ARGS, "execlp() of '%s' failed", mlmmjsend);
src/mlmmj-send.c +25 -5
diff -ru mlmmj-1.2.17/src/mlmmj-send.c mlmmj-1.2.17-mod/src/mlmmj-send.c
@@ -672,9 +672,9 @@
 
 static void print_help(const char *prg)
 {
-        printf("Usage: %s [-L /path/to/list || -l listctrl] \n"
-	       "       -m /path/to/mail [-a] [-D] [-F] [-h] [-r] [-R] "
-	       "[-s] [-T] [-V]\n"
+	printf("Usage: %s [-L /path/to/list || -l listctrl] \n"
+	       "       -m /path/to/mail [-a] [-D] [-F] [-h] [-o] [-r] [-R] "
+	       "[-R] [-s] [-T] [-V]\n"
 	       " -a: Don't archive the mail\n"
 	       " -D: Don't delete the mail after it's sent\n"
 	       " -F: What to use as MAIL FROM:\n"
@@ -689,6 +689,7 @@
 	       "    '7' means 'digest'\n"
 	       " -L: Full path to list directory\n"
 	       " -m: Full path to mail file\n"
+	       " -o: Address to omit from distribution (normal mail only)\n"
 	       " -r: Relayhost IP address (defaults to 127.0.0.1)\n"
 	       " -R: What to use as Reply-To: header\n"
 	       " -s: Subscribers file name\n"
@@ -704,7 +705,7 @@
 	int deletewhensent = 1, sendres = 0, archive = 1, digest = 0;
 	int ctrlarchive, res;
 	char *listaddr = NULL, *listdelim = NULL;
-	char *mailfilename = NULL, *subfilename = NULL;
+	char *mailfilename = NULL, *subfilename = NULL, *omit = NULL;
 	char *replyto = NULL, *bounceaddr = NULL, *to_addr = NULL;
 	char *relayhost = NULL, *archivefilename = NULL, *tmpstr;
 	char *listctrl = NULL, *subddirname = NULL, *listdir = NULL;
@@ -737,7 +738,7 @@
 	if(sigaction(SIGTERM, &sigact, NULL) < 0)
 		log_error(LOG_ARGS, "Could not install SIGTERM handler!");
 
-	while ((opt = getopt(argc, argv, "aVDhm:l:L:R:F:T:r:s:")) != -1){
+	while ((opt = getopt(argc, argv, "aVDhm:l:L:R:F:T:r:s:o:")) != -1){
 		switch(opt) {
 		case 'a':
 			archive = 0;
@@ -760,6 +761,9 @@
 		case 'm':
 			mailfilename = optarg;
 			break;
+		case 'o':
+			omit = optarg;
+			break;
 		case 'r':
 			relayhost = optarg;
 			break;
@@ -1179,6 +1183,22 @@
 			do {
 				res = getaddrsfromfd(&stl, subfd,
 						maxverprecips);
+				if(omit != NULL && maxverprecips > 1) {
+					for(i = 0; i < stl.count; i++) {
+						if(strcmp(stl.strs[i], omit)
+							== 0) {
+						    myfree(stl.strs[i]);
+						    stl.count--;
+						    while (i < stl.count) {
+							stl.strs[i] =
+								stl.strs[i+1];
+							i++;
+						    }
+						    stl.strs[stl.count] = NULL;
+						    break;
+						}
+					}
+				}
 				if(stl.count == maxverprecips) {
 					initsmtp(&sockfd, relay, smtpport);
 					if(verp) {
#1 lore raw

That bit about testing being successful...might need to change that... It doesn't work for moderated mail; my test of that just got clogged somewhere in the Internet and didn't arrive for a while!

Still feel free to offer any comments about the patch, or suggestions regarding implementing this for moderated mail, but also feel free to disregard it until I come back with something a bit more functional.

Cheers,

Ben.

Quoted 50 lines · Ben Schmidt

The attached patch adds a 'not me too' feature to mlmmj, where post senders are excluded from the post distribution so people don't get copies of their own mail. A number of people, particularly those who aren't familiar with traditional email mailing lists, prefer this. It applies on top of the tunables patch I emailed earlier (which I neglected to mention applies over 1.2.17).

Some info and design decisions:

I decided a simple boolean tunable would suffice for this, at least in the short term, and quite probably long term, too. For now, people who really want confirmation their mail has arrived on the list can always subscribe a nomail email to post from. I will devote my mind to how this could neatly be extended later if it seems warranted.

Thanks to Franky for getting me started on this. The from address in those low level sending functions is the envelope sender, so based on the list address, not the sender of the mail, though. The sender of the mail is parsed with the other mail headers in mlmmj-process. This means I needed to communicate that information from mlmmj-process to mlmmj-send. Commandline paramaters seemed the way most consistent with the rest of the program, so I added an option.

I also had to decide whether the tunable should be tested in mlmmj-process or mlmmj-send. I opted for mlmmj-process, as that's where most decisions about whether and where to send mail are made, and as a general rule it's best if commandline arguments can override tunables rather than be affected by them. Thus I added an '-o' option to omit a specified address. The alternative is making the option specify an originator address, and testing the tunable in mlmmj-send to see whether or not to omit them from the distribution.

I decided to do an extra pass through the recipients list in main() to do the filtering rather than modify the lower level functions, as the functions are used in numerous locations, but this filtering is only required once, so an interface change doesn't seem warranted, and iterating the recipients shouldn't be too slow, even for large lists.

Comments? Questions?

I have tested it and it works fine for me.

Could this be included in mlmmj?

The patch includes updating the php and perl web admin interfaces' tunables.pl file. Should I be CCing people of that code specifically?

Cheers,

Ben.

#2 lore raw
In reply to Ben Schmidt

Well, since I promised a patch but didn't get around doing it, I feel so guilty that I will test your patch as well, maybe I can help to figure out where the moderated problem thingie is.

Franky

On Mon, Jan 25, 2010 at 12:08 PM, Ben Schmidt <[email protected]

Quoted 77 lines

wrote:

That bit about testing being successful...might need to change that... It doesn't work for moderated mail; my test of that just got clogged somewhere in the Internet and didn't arrive for a while!

Still feel free to offer any comments about the patch, or suggestions regarding implementing this for moderated mail, but also feel free to disregard it until I come back with something a bit more functional.

Cheers,

Ben.

Quoted 51 lines · Ben Schmidt

The attached patch adds a 'not me too' feature to mlmmj, where post senders are excluded from the post distribution so people don't get copies of their own mail. A number of people, particularly those who aren't familiar with traditional email mailing lists, prefer this. It applies on top of the tunables patch I emailed earlier (which I neglected to mention applies over 1.2.17).

Some info and design decisions:

I decided a simple boolean tunable would suffice for this, at least in the short term, and quite probably long term, too. For now, people who really want confirmation their mail has arrived on the list can always subscribe a nomail email to post from. I will devote my mind to how this could neatly be extended later if it seems warranted.

Thanks to Franky for getting me started on this. The from address in those low level sending functions is the envelope sender, so based on the list address, not the sender of the mail, though. The sender of the mail is parsed with the other mail headers in mlmmj-process. This means I needed to communicate that information from mlmmj-process to mlmmj-send. Commandline paramaters seemed the way most consistent with the rest of the program, so I added an option.

I also had to decide whether the tunable should be tested in mlmmj-process or mlmmj-send. I opted for mlmmj-process, as that's where most decisions about whether and where to send mail are made, and as a general rule it's best if commandline arguments can override tunables rather than be affected by them. Thus I added an '-o' option to omit a specified address. The alternative is making the option specify an originator address, and testing the tunable in mlmmj-send to see whether or not to omit them from the distribution.

I decided to do an extra pass through the recipients list in main() to do the filtering rather than modify the lower level functions, as the functions are used in numerous locations, but this filtering is only required once, so an interface change doesn't seem warranted, and iterating the recipients shouldn't be too slow, even for large lists.

Comments? Questions?

I have tested it and it works fine for me.

Could this be included in mlmmj?

The patch includes updating the php and perl web admin interfaces' tunables.pl file. Should I be CCing people of that code specifically?

Cheers,

Ben.

#3 lore raw
In reply to Ben Schmidt

Attached is a second version of this patch. The comments below all still apply (and I have added another regarding this second part).

Quoted 32 lines

The attached patch adds a 'not me too' feature to mlmmj, where post senders are excluded from the post distribution so people don't get copies of their own mail. A number of people, particularly those who aren't familiar with traditional email mailing lists, prefer this. It applies on top of the tunables patch I emailed earlier (which I neglected to mention applies over 1.2.17).

Some info and design decisions:

I decided a simple boolean tunable would suffice for this, at least in the short term, and quite probably long term, too. For now, people who really want confirmation their mail has arrived on the list can always subscribe a nomail email to post from. I will devote my mind to how this could neatly be extended later if it seems warranted.

Thanks to Franky for getting me started on this. The from address in those low level sending functions is the envelope sender, so based on the list address, not the sender of the mail, though. The sender of the mail is parsed with the other mail headers in mlmmj-process. This means I needed to communicate that information from mlmmj-process to mlmmj-send. Commandline paramaters seemed the way most consistent with the rest of the program, so I added an option.

I also had to decide whether the tunable should be tested in mlmmj-process or mlmmj-send. I opted for mlmmj-process, as that's where most decisions about whether and where to send mail are made, and as a general rule it's best if commandline arguments can override tunables rather than be affected by them. Thus I added an '-o' option to omit a specified address. The alternative is making the option specify an originator address, and testing the tunable in mlmmj-send to see whether or not to omit them from the distribution.

Quoted 5 lines

I decided to do an extra pass through the recipients list in main() to do the filtering rather than modify the lower level functions, as the functions are used in numerous locations, but this filtering is only required once, so an interface change doesn't seem warranted, and iterating the recipients shouldn't be too slow, even for large lists.

To make it work for moderated mail, it saves a <cookie>.orig filealongside the file in $LISTDIR/moderation in which it writes the address extracted from the From: header if it is to be omitted from the distribution. listcontrol() picks this up and adds the -o argument to mlmmj-send when the mail is approved. mlmmj-maintd should remove these extra files along with their counterparts as they will be the same age, though this has not yet been tested.

Quoted 8 lines

Comments? Questions?

I have tested it and it works fine for me.

Could this be included in mlmmj?

The patch includes updating the php and perl web admin interfaces' tunables.pl file. Should I be CCing people of that code specifically?

And also the php-moderation script now.

Cheers,

Ben.

TUNABLES +6 -0
diff -ru mlmmj-1.2.17/TUNABLES mlmmj-1.2.17-mod/TUNABLES
@@ -217,3 +217,9 @@
 
    The content of this file is appended to mail sent to the list.
 
+ ��� notmetoo			(boolean)
+
+   If this file is present, mlmmj attempts to exclude the sender of a post
+   from the distribution list for that post so people don't receive copies
+   of their own posts.
+
contrib/web/perl-admin/conf/tunables.pl +6 -0
diff -ru mlmmj-1.2.17/contrib/web/perl-admin/conf/tunables.pl mlmmj-1.2.17-mod/contrib/web/perl-admin/conf/tunables.pl
@@ -205,3 +205,9 @@
 			  "Footer",
 			  "The content of this option is appended to mail sent to the list.");
 
+mlmmj_boolean("notmetoo",
+			  "Not me too",
+			  "If this is set, mlmmj attempts to exclude the sender of a post ".
+			  "from the distribution list for that post so people don't receive copies ".
+			  "of their own posts.");
+
contrib/web/php-admin/conf/tunables.pl +6 -0
diff -ru mlmmj-1.2.17/contrib/web/php-admin/conf/tunables.pl mlmmj-1.2.17-mod/contrib/web/php-admin/conf/tunables.pl
@@ -205,3 +205,9 @@
 			  "Footer",
 			  "The content of this option is appended to mail sent to the list.");
 
+mlmmj_boolean("notmetoo",
+			  "Not me too",
+			  "If this is set, mlmmj attempts to exclude the sender of a post ".
+			  "from the distribution list for that post so people don't receive copies ".
+			  "of their own posts.");
+
contrib/web/php-moderation/mlmmj-moderation.php +1 -0
diff -ru mlmmj-1.2.17/contrib/web/php-moderation/mlmmj-moderation.php mlmmj-1.2.17-mod/contrib/web/php-moderation/mlmmj-moderation.php
@@ -116,6 +116,7 @@
 	if (is_dir($mod_dir)) {
 		if ($dh = opendir($mod_dir)) {
 			while (($file = readdir($dh)) !== false) {
+				if( !ereg("^([0-9a-f]+)\$",$file) ) continue;
 				$full_path = $mod_dir . "/" . $file;
 				if(filetype($full_path) == "file"){
 					if(FALSE === ($input = file_get_contents($full_path))){

Only in mlmmj-1.2.17-mod/listtexts: Makefile

man/mlmmj-send.1 +5 -3
diff -ru mlmmj-1.2.17/man/mlmmj-send.1 mlmmj-1.2.17-mod/man/mlmmj-send.1
@@ -1,11 +1,11 @@
-.TH mlmmj-send "1" "September 2004" mlmmj-send
+.TH mlmmj-send "1" "January 2010" mlmmj-send
 .SH NAME
 mlmmj-send \- send mail to a mailinglist or similar
 .SH SYNOPSIS
 .B mlmmj-send
 [\fI-L\fR /path/to/list | \fI-l\fR listctrl] \fI\-m\fR /path/to/mail
-[\fI-a\fR] [\fI-D\fR] [\fI-F\fR] [\fI-h\fR] [\fI-r\fR] [\fI-R\fR] [\fI-s\fR]
-[\fI-T\fR] [\fI-V\fR]
+[\fI-a\fR] [\fI-D\fR] [\fI-F\fR] [\fI-h\fR] [\fI-o\fR] [\fI-r\fR] [\fI-R\fR]
+[\fI-s\fR] [\fI-T\fR] [\fI-V\fR]
 .HP
 \fB\-a\fR: Don't archive the mail
 .HP
@@ -21,6 +21,8 @@
 .HP
 \fB\-m\fR: Full path to mail file
 .HP
+\fB\-o\fR: Address to omit from distribution (normal mail only)
+.HP
 \fB\-r\fR: Relayhost IP address (defaults to 127.0.0.1)
 .HP
 \fB\-R\fR: What to use as Reply-To: header
src/listcontrol.c +26 -5
diff -ru mlmmj-1.2.17/src/listcontrol.c mlmmj-1.2.17-mod/src/listcontrol.c
@@ -105,7 +105,8 @@
 		const char *mlmmjbounce, const char *mailname)
 {
 	char *bouncenr, *tmpstr;
-	char *param = NULL, *conffilename, *moderatefilename;
+	char *param = NULL, *conffilename, *moderatefilename, *omitfilename;
+	char *omit = NULL;
 	char *c, *archivefilename, *sendfilename;
 	const char *subswitch;
 	struct stat stbuf;
@@ -604,7 +605,6 @@
 		}
 
 		sendfilename = concatstr(2, moderatefilename, ".sending");
-
 		if(stat(moderatefilename, &stbuf) < 0) {
 			myfree(moderatefilename);
 			/* no mail to moderate */
@@ -620,12 +620,33 @@
 			exit(EXIT_FAILURE);
 		}
 
+		omitfilename = concatstr(2, moderatefilename, ".omit");
+		if(stat(omitfilename, &stbuf) == 0) {
+			tmpfd = open(omitfilename, O_RDONLY);
+			if(tmpfd < 0) {
+				log_error(LOG_ARGS, "Could not open %s",
+						omitfilename);
+			} else {
+				omit = mygetline(tmpfd);
+				close(tmpfd);
+				chomp(omit);
+			}
+			unlink(omitfilename);
+			myfree(omitfilename);
+		}
+
 		log_oper(listdir, OPLOGFNAME, "%s moderated %s",
 				fromemails->emaillist[0], moderatefilename);
 		myfree(moderatefilename);
-		execlp(mlmmjsend, mlmmjsend,
-				"-L", listdir,
-				"-m", sendfilename, (char *)NULL);
+		if (omit != NULL)
+			execlp(mlmmjsend, mlmmjsend,
+					"-L", listdir,
+					"-o", omit,
+					"-m", sendfilename, (char *)NULL);
+		else
+			execlp(mlmmjsend, mlmmjsend,
+					"-L", listdir,
+					"-m", sendfilename, (char *)NULL);
 		log_error(LOG_ARGS, "execlp() of '%s' failed",
 					mlmmjsend);
 		exit(EXIT_FAILURE);
src/mlmmj-process.c +33 -3
diff -ru mlmmj-1.2.17/src/mlmmj-process.c mlmmj-1.2.17-mod/src/mlmmj-process.c
@@ -331,14 +331,15 @@
 int main(int argc, char **argv)
 {
 	int i, j, opt, noprocess = 0, moderated = 0;
-	int hdrfd, footfd, rawmailfd, donemailfd;
+	int hdrfd, footfd, rawmailfd, donemailfd, omitfd;
 	int subonlypost = 0, addrtocc = 1, intocc = 0, modnonsubposts = 0;
 	int maxmailsize = 0;
 	int notoccdenymails = 0, noaccessdenymails = 0, nosubonlydenymails = 0;
 	int nomaxmailsizedenymails = 0;
+	int notmetoo = 0;
 	char *listdir = NULL, *mailfile = NULL, *headerfilename = NULL;
 	char *footerfilename = NULL, *donemailname = NULL;
-	char *randomstr = NULL, *mqueuename;
+	char *randomstr = NULL, *mqueuename, *omitfilename;
 	char *mlmmjsend, *mlmmjsub, *mlmmjunsub, *mlmmjbounce;
 	char *bindir, *subjectprefix, *discardname, *listaddr, *listdelim;
 	char *listfqdn, *listname, *fromaddr;
@@ -920,6 +923,8 @@
 		}
 	}
 
+	notmetoo = statctrl(listdir, "notmetoo");
+
 	if(!moderated)
 		moderated = statctrl(listdir, "moderated");
 	if(moderated) {
@@ -934,6 +939,27 @@
 			exit(EXIT_FAILURE);
 		}
 		myfree(donemailname);
+		if (notmetoo) {
+			omitfilename = concatstr(2, mqueuename, ".omit");
+			omitfd = open(omitfilename, O_RDWR|O_CREAT|O_EXCL, S_IRUSR|S_IWUSR);
+			if (omitfd < 0) {
+				log_error(LOG_ARGS, "could not open %s",
+					    	    omitfilename);
+				myfree(mqueuename);
+				myfree(omitfilename);
+				exit(EXIT_FAILURE);
+			}
+			myfree(omitfilename);
+			if(writen(omitfd, fromemails.emaillist[0],
+					strlen(fromemails.emaillist[0])) < 0) {
+				log_error(LOG_ARGS,
+						"could not write omit file");
+				myfree(mqueuename);
+				exit(EXIT_FAILURE);
+			}
+			fsync(omitfd);
+			close(omitfd);
+		}
 		newmoderated(listdir, mqueuename, mlmmjsend, efrom);
 		return EXIT_SUCCESS;
 	}
@@ -946,7 +972,13 @@
 		exit(EXIT_SUCCESS);
 	}
 
-	execlp(mlmmjsend, mlmmjsend,
+	if (notmetoo)
+		execlp(mlmmjsend, mlmmjsend,
+				"-L", listdir,
+				"-o", fromemails.emaillist[0],
+				"-m", donemailname, (char *)NULL);
+	else
+		execlp(mlmmjsend, mlmmjsend,
 				"-L", listdir,
 				"-m", donemailname, (char *)NULL);
 	log_error(LOG_ARGS, "execlp() of '%s' failed", mlmmjsend);
src/mlmmj-send.c +25 -5
diff -ru mlmmj-1.2.17/src/mlmmj-send.c mlmmj-1.2.17-mod/src/mlmmj-send.c
@@ -672,9 +672,9 @@
 
 static void print_help(const char *prg)
 {
-        printf("Usage: %s [-L /path/to/list || -l listctrl] \n"
-	       "       -m /path/to/mail [-a] [-D] [-F] [-h] [-r] [-R] "
-	       "[-s] [-T] [-V]\n"
+	printf("Usage: %s [-L /path/to/list || -l listctrl] \n"
+	       "       -m /path/to/mail [-a] [-D] [-F] [-h] [-o] [-r] [-R] "
+	       "[-R] [-s] [-T] [-V]\n"
 	       " -a: Don't archive the mail\n"
 	       " -D: Don't delete the mail after it's sent\n"
 	       " -F: What to use as MAIL FROM:\n"
@@ -689,6 +689,7 @@
 	       "    '7' means 'digest'\n"
 	       " -L: Full path to list directory\n"
 	       " -m: Full path to mail file\n"
+	       " -o: Address to omit from distribution (normal mail only)\n"
 	       " -r: Relayhost IP address (defaults to 127.0.0.1)\n"
 	       " -R: What to use as Reply-To: header\n"
 	       " -s: Subscribers file name\n"
@@ -704,7 +705,7 @@
 	int deletewhensent = 1, sendres = 0, archive = 1, digest = 0;
 	int ctrlarchive, res;
 	char *listaddr = NULL, *listdelim = NULL;
-	char *mailfilename = NULL, *subfilename = NULL;
+	char *mailfilename = NULL, *subfilename = NULL, *omit = NULL;
 	char *replyto = NULL, *bounceaddr = NULL, *to_addr = NULL;
 	char *relayhost = NULL, *archivefilename = NULL, *tmpstr;
 	char *listctrl = NULL, *subddirname = NULL, *listdir = NULL;
@@ -737,7 +738,7 @@
 	if(sigaction(SIGTERM, &sigact, NULL) < 0)
 		log_error(LOG_ARGS, "Could not install SIGTERM handler!");
 
-	while ((opt = getopt(argc, argv, "aVDhm:l:L:R:F:T:r:s:")) != -1){
+	while ((opt = getopt(argc, argv, "aVDhm:l:L:R:F:T:r:s:o:")) != -1){
 		switch(opt) {
 		case 'a':
 			archive = 0;
@@ -760,6 +761,9 @@
 		case 'm':
 			mailfilename = optarg;
 			break;
+		case 'o':
+			omit = optarg;
+			break;
 		case 'r':
 			relayhost = optarg;
 			break;
@@ -1179,6 +1183,22 @@
 			do {
 				res = getaddrsfromfd(&stl, subfd,
 						maxverprecips);
+				if(omit != NULL && maxverprecips > 1) {
+					for(i = 0; i < stl.count; i++) {
+						if(strcmp(stl.strs[i], omit)
+							== 0) {
+						    myfree(stl.strs[i]);
+						    stl.count--;
+						    while (i < stl.count) {
+							stl.strs[i] =
+								stl.strs[i+1];
+							i++;
+						    }
+						    stl.strs[stl.count] = NULL;
+						    break;
+						}
+					}
+				}
 				if(stl.count == maxverprecips) {
 					initsmtp(&sockfd, relay, smtpport);
 					if(verp) {
#4 lore raw
In reply to Ben Schmidt

Thanks again for the offer of help, Franky. No worries that you didn't get around to the earlier patch; what you wrote in your email was a pretty good start and quite detailed, so helpful.

I think I've cracked the moderation thing! Wrote about it in another email.

Extra hands testing are always appreciated, especially because I have a pretty limited selection of list options in use myself.

Ben.

Quoted 104 lines · Franky Van Liedekerke

Well, since I promised a patch but didn't get around doing it, I feel so guilty that I will test your patch as well, maybe I can help to figure out where the moderated problem thingie is.

Franky

On Mon, Jan 25, 2010 at 12:08 PM, Ben Schmidt <[email protected] <mailto:[email protected]>> wrote:

That bit about testing being successful...might need to change that... It doesn't work for moderated mail; my test of that just got clogged somewhere in the Internet and didn't arrive for a while!

Still feel free to offer any comments about the patch, or suggestions regarding implementing this for moderated mail, but also feel free to disregard it until I come back with something a bit more functional.

Cheers,

Ben.

On 25/01/10 9:56 PM, Ben Schmidt wrote:

The attached patch adds a 'not me too' feature to mlmmj, where post senders are excluded from the post distribution so people don't get copies of their own mail. A number of people, particularly those who aren't familiar with traditional email mailing lists, prefer this. It
applies on top of the tunables patch I emailed earlier (which I neglected to mention applies over 1.2.17).

Some info and design decisions:

I decided a simple boolean tunable would suffice for this, at least in
the short term, and quite probably long term, too. For now, people who
really want confirmation their mail has arrived on the list can always
subscribe a nomail email to post from. I will devote my mind to how this
could neatly be extended later if it seems warranted.

Thanks to Franky for getting me started on this. The from address in those low level sending functions is the envelope sender, so based on
the list address, not the sender of the mail, though. The sender of the
mail is parsed with the other mail headers in mlmmj-process. This means
I needed to communicate that information from mlmmj-process to mlmmj-send. Commandline paramaters seemed the way most consistent with
the rest of the program, so I added an option.

I also had to decide whether the tunable should be tested in mlmmj-process or mlmmj-send. I opted for mlmmj-process, as that's where
most decisions about whether and where to send mail are made, and as a
general rule it's best if commandline arguments can override tunables
rather than be affected by them. Thus I added an '-o' option to omit a
specified address. The alternative is making the option specify an originator address, and testing the tunable in mlmmj-send to see whether
or not to omit them from the distribution.

I decided to do an extra pass through the recipients list in main() to
do the filtering rather than modify the lower level functions, as the
functions are used in numerous locations, but this filtering is only required once, so an interface change doesn't seem warranted, and iterating the recipients shouldn't be too slow, even for large lists.

Comments? Questions?

I have tested it and it works fine for me.

Could this be included in mlmmj?

The patch includes updating the php and perl web admin interfaces' tunables.pl <http://tunables.pl> file. Should I be CCing people of that code specifically?

Cheers,

Ben.

#5 lore raw
In reply to Ben Schmidt

Hi Ben,

Quoted 1 line · Ben Schmidt

The attached patch adds a 'not me too' feature to mlmmj

I can see that you've sent even more code, but I need to sleep a bit before I travel to Norway. Don't worry, I will look at it soon.

Morten

Signature · 3 lines
Morten Shearman Kirkegaard <[email protected]>
CTO, FableTech
http://fabletech.com/