Today, I got a csv phone book exported by Outlook Express. It is about 2,xxx email addresses. I need to import to the qmail mailing list (ezmlm). For 10-20 email addresses, I do not mind copy and paste in qmailadmin. Two thousand email addresses, no way. I started to write a tiny perl script.
Before writing the perl script, I wanted to find an easy way. I searched the CPAN. Fortunately, I found one: Ezmlm-0.07.2 By Lars Kruse devel@sumpfralle.de. You can download the package Ezmlm-0.07.2 here.
After install the package, I started my script as follows:
#!/usr/bin/perl
use Mail::Ezmlm;
$list = new Mail::Ezmlm;
$list = new Mail::Ezmlm ('/home/domains/yourdomain.com/newsletter');
# please change the newsletter directory accordingly.
open(LOG,"<./phonebook.csv")||&ErrorMessage;
@email = <LOG>;
close(LOG);
$n=1;
foreach $emailaddress (@email) {
$TEMP = $emailaddress;
$TEMP=~ s/\n//g; #remove line feeding if any
chop($TEMP); #remove line feeding if any
$list->sub($TEMP);
print "Inserting $TEMP to the mailling list\n";
$n++;
}
@subscribers = $list->subscribers;
You can download the above code importing mailing list here. Remember to chmod 755.