Hello everyone,
I'm back again with another problem.
Here's what I've got:
A user comes to the site, wanting to sign-up
for A, B, and(or) C news letter.
They fill-out and submit the questions which
are stored in a mysql database.
Now, the editor (not very computer savy) has an address they can pull up with their browser, click which newsletter (news1 or news2) they will be submitting to,
fill in the body with whatever it is they will be sending to everyone signed up to receive this specific email, and click submit. Once submitted, it searches the db
for all rows that "yes" in the news1 (and/or) news2 field, extracts the email addy, and sends the email to that list.
The Problem: It's not working, and I'm not sure why.
The Code for the emailer:
#!/usr/local/bin/perl -w
$mailprog = '/bin/mailx';
use CGI qw(:standard);
use CGI::Carp qw/fatalsToBrowser/;
use DBI;
use Mail::Sender
$drh = DBI->install_driver( 'mysql' );
$dbh=$drh->connect("DBName","User","PassWd");
die unless $dbh;
$from_address = param('from_address');
$to_address = param('to_address');
$subject = param('subject');
$body = param('body');
$email = param('email');
if (!($from_address) | | !($body) | | !($subject)) {
print "Content-Type: text/htmlnn";
exit;
}
if ($news1) {
$list_q = "SELECT email FROM users where news1='Yes'";
}
if ($news2) {
$list_q = "SELECT email FROM users where news2='Yes'";
}
######################################
# Connecting to SQL to grab the event
######################################
$query=$dbh->prepare($list_q);
$query->execute;
$rows=$query->rows;
while(@user = $query->fetchrow) {
if (!$user[0]) {
next;
}
## Mail::Sender
ref ($sender = new Mail::Sender({from => '"$from_address"',smtp => 'mail.oklahoman.com'})) or die "$Mail::Sender::Errorn";
(ref ($sender->MailMsg({to =>'"$user[0]"', subject => '"$subject"', msg => "$body"}))
and
print "Content-Type: text/htmlnn";
if ($news1) {
print "<h2>Your message has been sent.</h2>";
}
if ($news2) {
print "<H2>Your message has been sent.</H2>";
}
Thank you in advance for any help you may be able to offer.
-Loki