I wrote a quick program today to filter a list of email addresses out of an old email that had been forwarded a couple times. The program itself is very simple, but it took me about 15 minutes. Most of that time was digging up the proper commands for reading in the input.
I think it's mostly because I haven't written any new Perl code in about 2 years. I need to find an excuse to write more Perl so I'm not so rusty when I need.
#!/usr/bin/perl use IO::Handle; open (INPUT, ") { chomp $email; $email =~ s/^ *?>> +?(.+?),.*$/$1/; print "$email; "; } close (INPUT);
There isn't an easy way to do it. I've looked, but that's never stopped me before. I will finish out this post later, but for now, I'm getting the details in so I don't forget.
Requirements: (To do it the way I did.)
- *.txt files from Mailman's list archives
- Unix shell and FTP access
- unix2dos command for Unix
- minimail - Cut+paste perl code to parse/create mbox files and mail messages
- Mark Lyon's GMail Loader (GML)
- A POP email account
- Outlook
Overview:
- Combine *.txt files for a list into one *.mbox file. (cat *.txt > listname.mbox)
- Append headers using minimail.pl.
- Convert to DOS text file format.
- Send to POP account using GML.
We append the "Sender:" and "To:" headers so that the rules I use in Outlook will auto sort them.
Append Headers Code: (Replace the last {} block in minimail.pl with this, making appropriate changes for each list.)
{
sub rd { <> }
formail(&rd, sub {
my $mymail = shift;
append_header($mymail, "To: 'List Description' ");
append_header($mymail, "Sender: listname-bounces@listserver.com");
print mail2str($mymail);
});
}
To Do List:
- Need to unobscure the email addresses so they aren't all "user at server.com".
In the process of moving to a new web server, I came across a small problem. On the old server, I'd been using Cryus for IMAP access. On the new server, to simplify things with Webmin/Virtualmin, I'm using IMAP-UW instead. It suits my purposes without overcomplicating matters like Cryus seemed to. The problem is that Cyrus uses a directory of email files and IMAP-UW uses one MBOX file with all the messages. I found several programs to convert from MBOX to Cyrus's format, but nothing to go the other way. After a lot of playing, I finally created something that works. And it works pretty well too.



