On 18/10/2006, at 10:05 PM, Nicholas Tomlin wrote:

James,

Yes, I had thought of that, but my scripting is woefully non existant, I have the misfortune of being a [ugh] desk top user hemmed in by the ongoing use
and convenience of a GUI, I can talk the talk, but as for walking, I'm
legless..

Maybe someone as knowlegable as yourself could point me in the right
direction...

Ok, here's an idea. Assuming your Kmail is configured to use maildir and the "root" of your mail store is ~/Mail, let's see if I can bash something out for you. If you're using "mbox", this script should still work (I think).

---- Begin: mail-farm.sh ----
#!/bin/bash

# Make any generated files only readable by moi
umask 077

# Define some variables first
MAILROOT=~/Mail
TMP=/tmp/mail-addresses.tmp
OUT=~/mail-addresses.txt

# Now step through the mail store one file (message) at a time
for MSG in `find $MAILROOT -print -type f`
do
    # Each message we find - rip out the e-mail address
    # The sed command isn't mine - I got it from here:
    # http://sed.sourceforge.net/grabbag/tutorials/sed1line.txt

egrep '^From:' $MSG | sed 's/ *(.*)//; s/>.*//; s/.*[:<] *//' >> $TMP
done

# Now just sort it, and rip out dupicates.  We need to sort, as 'uniq'
# expects a sorted list - see "man uniq"
cat $TMP | sort | uniq >> $OUT

# Clean up - just like yo mamma learned ya!
rm -f $TMP >/dev/null 2>&1

---- End:  mail-farm.sh ----

The 'sed' match isn't perfect and tends to leave cruft occasionally at the end of some addresses (usually messages sent from Microsoft mailers!). But you said you were going to "audit" the list before using it, so it's not a big deal.

Once you've got the list all cleaned up, you can simply fire off your mail. I generally use "mutt" for this sort of thing as it will handle attachments and such, plus uses a simple environment variable to define your e-mail (sender's) address. Assume you have already written a message and stored it in a plain text file: ~/message.txt

export [EMAIL PROTECTED]
for RECIP in `cat ~/mail-addresses.txt`
do
    mutt -s "My new e-mail address" -i ~/message.txt $RECIP
done

Voila! Now every person receives an individual message from you with your new address (assuming your MTA on your machine is configured correctly). All of this is relatively untested but should mostly work. I'd test the "mutt -s...." line with a single address instead of "$RECIP" in a loop before actually running this. The last thing you want is 1600 people getting a borked e-mail from you :P

Here's some light reading for you to assist in any debugging:
man umask
man egrep
man sort
man uniq
man mutt
man bash

...and if you're really lost:
man man

Cheers,

James


Attachment: smime.p7s
Description: S/MIME cryptographic signature

-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to