[plug] Mailing List problems

Joong Cho joongcho at westnet.com.au
Sat Jan 8 21:01:08 WST 2005


Hello everyone,

Happy New Year to you all.

I have a brand new problem for the year 2005 and I have yet to configure my 
mail server. :(

Anyway, I'm sending a mailing list using a perl script and everytime I run 
this file, it seems to add "@joongcho.com" after the email address in the To 
part. For example: To: "joongcho at westnet.com.au"@joongcho.com.

The following is the code that I'm using for the perl script. Am I better 
off using a PHP file for a mailing list type program or will perl script 
suffice as I long as I fix this problem?

#!/usr/bin/perl

$count = 0;

use DBI;

my $dbh = DBI->connect('DBI:mysql:joongs_email','<username>','<password>');

my $query = $dbh->prepare("select * from email_list");
$query->execute;

while (my($firstName,$lastName,$email,$typeVersion)=$query->fetchrow_array)
{
# print $firstName, " ", $lastName, " ", $email, " ", $typeVersion, "\n";

 $Email = $email;
 $Version = $typeVersion;

 if ( $Email =~ s/\@/\\\@/gi )
 {
  print "$Email\n";
 }
 else
 {
  print "No Email found\n";
 }

 if ( $Version eq "HTML")
 {
  &sendHTML;
 }
 else
 {
  &sendText;
 }
}

sub sendHTML()
{
 ($day, $month, $dayOfMonth, $rest) = split(/\s+/,localtime(time),4);

 ($hour, $minute, $second, $rest) = split(/:/,$rest,4);

 ($second, $year) = split(/\s+/,$second);

 ($day, $month, $dayOfMonth, $time) = split(/\s+/,localtime(time));

 ($hour, $minute, $second) = split(/:/,$time);

 @day = ("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", 
"Sunday");

 open (MAIL, "|/usr/sbin/sendmail -t") || die "Can't open pipe to sendmail 
\n";

 print MAIL "To: $Email\n";
 print MAIL "From: mailbag\@joongcho.com\n";
 print MAIL "Subject: Site Update - $day $dayOfMonth $month, $year\n";

 print MAIL "Content-type: text/html\n\n";

 print MAIL "<html>\n";
 print MAIL "<head>\n";
 print MAIL "<title>Site Update - 11 July, 2003</title>\n";
 print MAIL "</head>\n\n";

 print MAIL "<body bgcolor=\"#FFFFFF\" text=\"#000000\">\n\n";

 print MAIL "<p><center><img 
src=\"http://192.168.1.11/~joongcho/Images/headernew-a.gif\"></center>\n\n";

 print MAIL "<p><table border=0 cellspacing=0 cellpadding=3>\n";
 print MAIL "<tr>\n";
 print MAIL "<td valign=top><img 
src=\"http://192.168.1.11/~joongcho/Images/portrait_new.jpg\" align=left ";
 print MAIL "hspace=0></td>\n";
 print MAIL "<td valign=top><p><font face=\"arial\" size=\"2\">Ladies and 
gentlemen,\n";
 print MAIL "<p>I have done some updates to my website.\n";
 print MAIL "<p>The following is what I have updated:\n";
 print MAIL "<p><h1><b>MOVIE REVIEWS</b></h1>\n";
 print MAIL "<p><ul>\n";
 print MAIL "<li>Update my movie review page to include review for ";
 print MAIL "\"<a 
href=\"http://www.joongcho.com/reviews/hulk.htm\">Hulk</a>\".\n";
 print MAIL "</ul>\n";
 print MAIL "</tr>\n";
 print MAIL "</table>\n";
 print MAIL "<table border=0 cellpadding=0 cellspacing=0>\n";
 print MAIL "<tr>\n";
 print MAIL "<td colspan=2><font face=\"arial\" size=\"2\">\n";
 print MAIL "<p>Thank you for visiting my site\n";
 print MAIL "<p>JC<br>\n";
 print MAIL "Joong Cho Enterprises<br>\n";
 print MAIL "President\n\n";

 print MAIL "<p>Home: 9354 1835<br>\n";
 print MAIL "Business: 9354 7178\n";

 print MAIL "<p>Web Site Administrator and Web Site Designer<br>\n";
 print MAIL "<a href=\"http://www.joongcho.com/\" 
target=\"_parent\">http://www.joongcho.com/</a><br>\n";
 print MAIL "<a href=\"http://www.startreklibrary.com\" \n";
 print MAIL 
"target=\"_parent\">http://www.startreklibrary.com/</font></td>\n";
 print MAIL "</tr>\n";
 print MAIL "</table>\n";

 print MAIL "</body>\n";
 print MAIL "</html>";

 $count++;

 close (MAIL);
}

sub sendText()
{
 ($day, $month, $dayOfMonth, $rest) = split(/\s+/,localtime(time),4);

 ($hour, $minute, $second, $rest) = split(/:/,$rest,4);

 ($second, $year) = split(/\s+/,$second);

 ($day, $month, $dayOfMonth, $time) = split(/\s+/,localtime(time));

 ($hour, $minute, $second) = split(/:/,$time);

 @day = ("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", 
"Sunday");

 open (MAIL, "|/usr/sbin/sendmail -t") || die "Can't open pipe to sendmail 
\n";

 print MAIL "To: $Email\n";
 print MAIL "From: mailbag\@joongcho.com\n";
 print MAIL "Subject: Site Update - $day $dayOfMonth $month, $year\n";

 print MAIL "Content-type: text/plain\n\n";

 print MAIL "Ladies and gentlemen\n\n";

 print MAIL "I have done some updates to my website.\n\n";

 print MAIL "The following is what I have updated:\n\n";

 print MAIL "MOVIE REVIEW PAGE:\n\n";

 print MAIL "Updated my movie review page to include review for Hulk.\n";
 print MAIL "Go to http://www.joongcho.com/reviews/hulk.htm to take a 
look.\n\n";

 print MAIL "Thank you for visiting my site\n\n";

 print MAIL "JC\n";
 print MAIL "Joong Cho Enterprises\n";
 print MAIL "President\n\n";

 print MAIL "Home: 9354 1835\n";
 print MAIL "Business: 9354 7178\n\n";

 print MAIL "Web Site Administrator and Web Site Designer\n";
 print MAIL "http://www.joongcho.com/\n";
 print MAIL "http://www.startreklibrary.com/\n";

 print MAIL "\n";

 $count++;

 close (MAIL);
}

print "\nYou sent $count emails\n";

Thanks in advance.

Joong Cho
Joong Cho Enterprises
President

Web Site Administrator and Web Site Designer
http://www.joongcho.com/
http://www.startreklibrary.com/ 





More information about the plug mailing list