Here are the subroutines I use to get the information to send as well as send the mail. The To, from, Subject, information are all passed to this script from a form. I've tried to remove the "!!" from $article, with the no luck. I imagine that it's adding that information when it clears a buffer or something.
I'm using an ISP to host my site and don't think I can use MAIL::SEND. I'll look into it.
#this subroutine opens the mailing program and sends the emails
#if a copy has been requested, it sends that out, too.
sub mail_article
{
open(MAIL,"|$mailprog -t");
if ($z == 2)
{
print MAIL "To: $emailname\n";
}
else {
print MAIL "To: $FORM{'emailto'}\n";
}
print MAIL "From: \"$FORM{'fromname'}\" \<$FORM{'emailfrom'}\>\n";
print MAIL "X-IP_Address: $ENV{REMOTE_ADDR}\n";
print MAIL "Subject: $FORM{'title'}\n";
if ($FORM{'atype'} eq "full")
{
print MAIL "Content-Type: text/html\n";
}
else
{
print MAIL "Content-Type: text/plain; charset=\"us-ascii\"\n";
}
$printline = 0;
if ($FORM{'atype'} eq "full")
{
print MAIL "<html><body>\n";
&get_mailtext;
print MAIL "<font face=\"helvetica, arial, sans-serif, verdana\" size=
+\"2\">\n";
print MAIL "<b>$FORM{'fromname'} ($FORM{'emailfrom'}) </b>has sent you
+ a news article.</a></font><br><br>\n";
if ($FORM{'msg'} ne "")
{
print MAIL "<font face=\"helvetica, arial, sans-serif, verdana\" size=
+\"2\"><b>Personal Message:</b><br>$FORM{'msg'}<br><br></font>\n";
}
print MAIL "<font face=\"helvetica, arial, sans-serif, verdana\" size=
+\"2\" color=\"#006633\"><b>$FORM{'title'}</b></font><br><font face=\"
+helvetica, arial, sans-serif, verdana\" size=\"2\"><a href=\"$FORM{'l
+ink'}\">Link to article</a><br><br><hr size=\"1\" noshade></font>\n";
}
#output only the link
else {
print MAIL "$FORM{'fromname'} ($FORM{'emailfrom'}) has sent you a news
+ article.\n\n\n";
if ($FORM{'msg'} ne "")
{
print MAIL "Personal Message:\n";
print MAIL "$FORM{'msg'}\n\n";
}
print MAIL "$FORM{'title'}\n";
print MAIL "$FORM{'link'}\n\n\n";
print MAIL "----------------------------------------------------";
}
if ($FORM{'atype'} eq "full")
{
$count = 1;
if ($count == "1")
{
$article =~ s/\<html\>//g;
$article =~ s/\<\/html\>//g;
print MAIL "<div align=\"center\"><font face=\"helvetica, arial, sans-
+serif, verdana\" size=\"2\" color=\"#006633\"><b>$headline</b></font>
+<br>\n";
print MAIL "<font face=\"helvetica, arial, sans-serif, verdana\" size=
+\"1\">$byline</font><br><br></div>\n";
print MAIL "<font face=\"helvetica, arial, sans-serif, verdana\" size=
+\"2\">\n";
print MAIL "$article\n";
print MAIL "</font><br><br><font face=\"helvetica, arial, sans-serif,
+verdana\" size=\"1\">$disclosure<br><br>$p_offerh<br><br>\n";
print MAIL "© 2001 All rights reserved.</font></body></html>\n";
}
$count++;
}
else {
#print MAIL "\n$disclosure\n\n";
#print MAIL "$p_offer\n\n";
}
close MAIL;
#opens the database file to get the information to mail
sub get_mailtext
{
#variables
$LOCK_EX = 2;
$LOCK_UN = 8;
open (DATABASE, "./file.txt"); #open database for reading
flock(DATABASE, $LOCK_EX);
@data=<DATABASE>;
foreach $Story (@data)
{
my $temptitle = $FORM{'title'};
my $id = $FORM{'id'};
@Temp = split(/\|/, $Story);
if (($Temp[2] eq "$temptitle") && ($Temp[0] eq "$id"))
{
$id = "$Temp[0]";
$headline = "$Temp[2]";
$byline = "$Temp[3]";
$article = "$Temp[5]";
$article =~ s/\! \! //g;
$article =~ s/\!\!//g;
$p_offer = "Please read the information carefully before you inves
+t or send money.\n";
$p_offerh = "Please read the information carefully before you inve
+st or send money.\n";
$disclosure = "$Temp[6]";
}
}
flock(DATABASE, $LOCK_UN);
close(DATABASE);
}
2001-03-29 Edit by Corion : Added formatting and CODE tags. |