Hello, I'm working on our company newsletter, for our employees, that is sent out via email. What I am trying to do is to replace a bracketed tag NAME, that is embedded within the template, with the name of the person in the database. What I am finding is that the first person's name in the db is being retained in the template when being sent instead of being replaced by the person the message is intended for. What step am I missing to resolve this issue?
open (FILE, "$datadir/sendme.txt") || &error_message("Can't file temp
+ file for sending mail - $datadir/sendme.txt.");
$sendthis = <FILE>;
close(FILE);
if ($action eq 'moremail')
{
$osubject = $INFO{'osubject'};
$usename = $INFO{'usename'};
$obname = $INFO{'obname'};
$oaname = $INFO{'oaname'};
$list = $INFO{'list'};
$osubject =~ s/_/ /g;
$osubject =~ s/%26/\&/g;
$oaname =~ s/_/ /g;
$oaname =~ s/%26/\&/g;
$obname =~ s/_/ /g;
$obname =~ s/%26/\&/g;
}
else
{
$startat = 0;
}
open (FILE, "$datadir/$list\.txt") || die "Can't open $datadir/lists\
+.txt\n";
@info = <FILE>;
close(FILE);
$num = @info;
$endat = $startat + $increment;
$lastone = 0;
if ($num < $endat)
{
$endat = $num;
$lastone = 1;
}
for ($a = $startat; $a < $endat; $a++)
{
($name,$recipient,$nochop) = split(/,/,$info[$a]);
if ($recipient =~ /.*\@.*\..*/)
{
open (MAIL, "|$mailprog") || die "Can't open $mailpro
+g!\n";
print MAIL "To: $recipient\n";
print MAIL "From: $omultiname < $omultimail >\n";
print MAIL "Subject: $osubject\n";
print MAIL "Content-type: text/html;\n\n
+";
if ($usename eq 'yes')
{
print MAIL "$obname $name$oaname<BR>\n\n";
$sendthis=~s/\[NAME\]/$name/gie;
}
print MAIL $sendthis, "\n";
close (MAIL);
}
}
Any help would be greatly appreciated! Lisaw
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.