Re: Archive to mbox? and other questions

Hans-Albert Schneider <[email protected]> Sun, 11 Jul 2004 23:40:18 +0200
Newsgroups gmane.mail.smartlist.user
Message-ID <[email protected]>
On Wednesday 07 July 2004 21:17, Gary Weinfurther wrote:
> I have a few smartlist questions:
>
> 1.  How can I save messages to an mbox file, where I can search it
> quicker and easier than opening thousands of individual message
> files? Ideally, I'd like to group the messages into mbox files by
> month.

Try something like this in rc.local.s20:

	month=`date '+%h%y'`
	archive2="archive/$month"

	:0 c
	${archive2}

This will create archive/Jul04 etc. If you prefer archive/2004-07 etc, 
use
	month=`date '+%Y-%m'`

BTW, this is a variation of "rc.local.s20.mmmyy" from my little recipe 
collection at
	http://www.ha-schneider.de/software/smartlist/


> 2. I have an existing database of users, and I will be creating a
> web page where they can log in, see which lists they are subscribed
> to, and change their subscriptions.  What is the best way to
> synchronize a database of user enrollments with the dist list? 
> Should I rewrite the dist file from the database each time?  The
> alternative method of sending an email with an XCommand seems like
> so much overhead, particularly since I don't want any email
> response to the command, and because I may need to subscribe a
> large number of users at once. [...]

Sounds like you are really going to rewrite the dist file from the 
database. Some remarks:

1) Only the "naked" mail addresses go there; i.e.,
	[email protected]
not
	Gary Weinfurther <[email protected]>

2) Put one address per line.

3) Lock the list while updating ("lockfile rc.lock"); only update if 
you got the lock.
If updating takes more than a few minutes, or may break or fail, build 
a file dist.new, and when successfully done, do
	lockfile rc.lock && cat dist.new > dist && rm -f rc.lock

4) The line reading "(Only addresses below this line can be 
automatically removed)" *must* be present. I suggest you make it the 
first line, so auto-removal still sort of works for bouncing 
addresses (see below).

5) You may want to offer your subscribers to specify alternative 
addreses from which they are submitting to the lists. These would go 
to the accept file, together with the subscribed addresses. Of 
course, you need to
	../.bin/delink accept
for this to work.

6) If you are expecting many subscriptions and unsubscriptions within 
short periods of time, you may want to do the rewriting per cron job 
(see "man crontab").


Concerning auto-removal: Of course the auto-removal of bounced 
addresses only sort of "works", because some time after removal, the 
dist file will be regenerated with the bouncing address again in it. 
You should therefore create your own version of the procbounce script 
and have it take actions that are appropriate for your setup, e.g., 
marking the mail address as "bouncing" in the database. You must then 
skip addresses bearing this mark when generating the dist file.

As the reasons for bouncing are sometimes temporary, tell your users 
(on the web form) that their address caused a problem, and allow them 
to remove the mark after some time.  You can also test the marked 
addresses every few days by sending them an e-mail.  The e-mail could 
read "your mail address was unreachable and has therefore been 
removed from our mailing lists. To reactivate your subscriptions, 
follow on this link:" If they click on the link, this shows that the 
problem has gone (they got the mail), and the link could point to a 
web form that simply unmarks the address (so it should contain the 
mail address or the user ID.)
If you provide a web archive for the lists (see my link above for 
doing this with MHonArc), they do not even loose mails.  Your 
reactivation page may point them to the archives.


> [...]  Why isn't there a simple script,
> ala Mailman, for handling admin functions?

	cd /where/ever/listname
	lockfile rc.lock
	if lock was successful:
		edit dist, or rc.custom, or rc.local.*
		rm -f rc.lock

Does this really require a script?

E.g., for mass subscription (in out-of-the-box SmartList, not your 
intended setup), you would replace the 4th line ("edit ...") by

	mv dist dist.old
	fgrep "(Only addresses below" dist.old > dist
	fgrep -v "(Only addresses below" dist.old \
		| sort -u - new-addresses >> dist
	rm dist.old

(assuming that the new mail addresses are in a file called 
"new-addresses" in the list directory).

When you generate the dist file, that 4th line will be replaced by the 
updating code.


Hans-Albert

-- 
Hans-Albert Schneider
Munich, Germany
EMail: [email protected]