I don't remember where I found this, but here is a script called "Email Grabber" that pulls the addresses out of the Links database.
Code:
#!/usr/local/bin/perl
#
# Change this to reflect your server's configuration
#
# -------------
# Links
# -------------
# Links Manager
#
# File: emailgrabber.cgi
# Description: Rips contact information from Links 2.0 database
# Author: Ryan Jensen
# Email:
jensen_ryan@hotmail.com # Web:
http://www.rjhypermedia.com # Version: 0.1
#
# main (c) 2001 R. J. Hypermedia (Ryan Jensen)
# some (c) 1998
Gossamer Threads Inc.
#
# This script relies heavily on work done by Alex Krohn for Gossamer
# Threads, Inc. I have simply made an easy script out of code taken
# from nph-email.cgi.
#
# This file should be placed in your password-protected "admin" dir-
# ectory and be renamed to "emailgrabber.cgi". To run, simply call
# "emailgrabber.cgi" under the correct path in your admin directory.
# It spits out all valid, unique, and not-opted-out emails in your
# database and the contact's name. It breaks contact information
# into lines 20 entries long (to prevent spam shutoff of many email
# providers). Printout can be used either in the "To:" field or the
# "BCC:" field of new email. I recommend using BCC to prevent link
# owners from seeing all others' contact information. It also prints
# out a total of contact information used.
#
# I created this script because I had problems with Hypermart disabling
# "nph-email.cgi" whenever I tried to email link owners. After 40
# successful messages sent, nph-email.cgi would freeze up and its
# permissions would be changed to 000. This was no way to get through
# 900+ messages. I now use the printouts to email 20 link owners at
# a time.
#
# On my server at Hypermart the script spits out 909 units of contact
# information in about 5 seconds. Should work on any configuration.
# I'm not sure if this script would work with Links 1.0. If you have
# any success with Links 1.0, please write me and let me know.
# ===================================================================== # Required Librariers
# --------------------------------------------------------
BEGIN {
eval {
($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1"); # Get the script location: UNIX /
($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1"); # Get the script location: Windows \
require "links.cfg"; # Change this to full path to links.cfg if you have problems.
require "$db_lib_path/db_utils.pl";
require "$db_lib_path/links.def";
require "$db_lib_path/Mailer.pm";
};
if ($@) {
print "HTTP 1.0/200 OK\n";
print "Content-type: text/plain\n\n";
print "Error including libraries: $@\n[/url]";
print "Make sure they exist, permissions are set properly, and paths are set correctly.";
exit;
}
}
# ========================================================
eval { &main; }; # Trap any fatal errors so the program hopefully
$@ and &cgierr("Fatal error: $@"); # never produces that nasty 500 server error page.
exit;
sub main {
print "Content-type: text/plain\n\n";
$count = 1;
open (DB, "<$db_links_name") or &cgierr("unable to open database: $db_links_name. Reason: $!");
while (<DB>) {
/^#/ and next; # Skip comment Lines.
/^\s*$/ and next; # Skip blank lines.
chomp;
@data = &split_decode($_);
($data[$db_mail] eq 'No') and (next);
($seen{$data[$db_contact_email]}++) and (next);
($data[$db_contact_email] =~ /.+@.+\..+/[/url]) or (next);
# print $data[$db_contact_name];
# print " <";
print $data[$db_contact_email];
# ($count % 20 != 0) and print ">, ";
# ($count % 20 == 0) and print ">\n";
($count % 20 != 0) and print ", ";
($count % 20 == 0) and print "\n";
$count += 1;
}
print "\n\n";
print $count;
}
# That's it!