Gossamer Forum
Home : Products : Links 2.0 : Customization :

Outputting email addresses to another file during build.

Quote Reply
Outputting email addresses to another file during build.
Hello all,

Gotta love Links 2.0!!

I use Mojo mail to email the link owners on my site.

While building my database, I would like to be able to automatically open up the Mojo email database and add the link owners' email address to it.

The Mojo mail database is a simple text file with one email address per line.

I have no trouble messing around with CGI, or modifying and troubleshooting scripts, but I can't for the life of me write a customized function within a script.

Can someone give me a quick routine to output these email addresses.

Thanks in advance,

::brendan::
Quote Reply
Re: [brendan] Outputting email addresses to another file during build. In reply to
Could you post an example format for the Links 2 email database? I havn't used it in a while, so will need to see the format before I can write a simple parser/writer to place in nph-build.cgi for you :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [brendan] Outputting email addresses to another file during build. In reply to
How would you make sure that duplicates were not added to the email db during each build?

I know that Mojo has its own duplicate checker, but I think it only works if you're trying to add duplicate emails through the Mojo system.

Thanks Smile

------------------------------------------
Quote Reply
Re: [Andy] Outputting email addresses to another file during build. In reply to
Andy,

Do you want to see the Links 2 email database, or did you mean to say the Mojo email database.

Either way, I'll put it up here tonight when I get home.

Thanks for your help,

Brendan
Quote Reply
Re: [DogTags] Outputting email addresses to another file during build. In reply to
DogTags,

Thank you. You bring up a good point.

This is the reason I don't write code...too much to think about, not enough thinking power!

I suppose that I would have to implement a duplicate checker into the code as well.

Would any kind soul please assist with the code to first check the database for a duplicate entry.

Once again, thanks in advance.

::brendan::
Quote Reply
Re: [brendan] Outputting email addresses to another file during build. In reply to
Andy,

I think you meant to ask for the Mojo email list. It follows the format that follows:



Thanks again for your help,

::brendan::
Quote Reply
Re: [brendan] Outputting email addresses to another file during build. In reply to
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!


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Outputting email addresses to another file during build. In reply to
Hi Leonard,

Thanks for the post.

I think I'll use that script for something else I had in mind, but it doesn't quite do what I need in this situation.

I need to add a section to my nph-build.cgi to make a list of all email addresses, check for duplicates in my mojo mail database, and then add any non-duplicate email addresses to that database.

Thanks again, in advance.

Brendan
Quote Reply
Re: [brendan] Outputting email addresses to another file during build. In reply to
It would be very nice!

One other thing to keep an eye on would be people who have signed off the list, as adding them again would not be advisable
Blacknight Solutions - Hosting
Search.ie
Armchair.ie
Quote Reply
Re: [blacknight] Outputting email addresses to another file during build. In reply to
If you have access to shell, you can try this to extract any number of fields from a database:

1. Make a new file and call it chomp.pl:

#--------------------------
while (<> ) {
chomp;
@data = split /\|/;
print $data[15], " ", "\n";
}
#--------------------------


Where it says $data[XX], replace with the Field ID of the field you want to extract. You can put numerous fields to extract by copying $data[15], and putting it after a space (" ").

2. In shell, type:

cat links.db | perl chomp.pl > email.db

This example will make an 'email.db' file with one e-mail address per line. Perfect for MojoMail. I use it.

-digitalsea
http://www.digital-sea.com/

Last edited by:

digitalsea: Jul 25, 2003, 5:35 AM
Quote Reply
Re: [digitalsea] Outputting email addresses to another file during build. In reply to
Excellent! I'll give it a try and see how I get on - thanks Wink
Blacknight Solutions - Hosting
Search.ie
Armchair.ie
Quote Reply
Re: [blacknight] Outputting email addresses to another file during build. In reply to
Opps, forgot to mention how I integrate new subscribers to my list...



For example if you go to: http://www.digital-sea.com/cgi-bin/add.cgi

And fill in the form, when it gets to modify_success.html it asks you to 'verify' your application submission. At this point the application is already submitted, but the Verify button is a hidden field for Mojo mail. This uses all the standard Links calls like <%Contact Email%> and allows me to automatically dispatch a welcome/subscribe e-mail to their address. Then they have the option to subscribe to the list or not.

-digitalsea
http://www.digital-sea.com/