Using sendmail 2 copies get sent to each user

M

mike

I have a basic script that has been rrrunning for years. All of a
sudden my users get 2 copies of each.

Here is my code below. I am getting 2 copies when this is executed.

Mike

#!/usr/bin/perl
#
# name of this program is: hb_mail_test.cgi
#
# this script automatically sends email just to (e-mail address removed)
#

use strict;
use MIME::Lite;

# The base path to the hbdata files
my $filebase = "/blah";

#The file being checked
my $file = "file.txt";

# The file fully qualified
my $selected = "$filebase/$file";

my $mymsg = "Hi this is Me!<br><br>";

#open the file and read it
open MAILFILE, "<$selected" or die "Cant open \n"; #open the file for
reading

while ( <MAILFILE> )
{
$mymsg = $mymsg . "$_";
}
#close the open file you were reading
close MAILFILE or die "Cant close \n";

$mymsg = $mymsg . "<br><br>Sincerely, Mike";

print "Content-type:text/html\n\n";
print "<HTML>\n";
print "<HEAD>\n";
print "<TITLE>Mail Send</TITLE>\n";
print "</HEAD>\n";

print "This will show the mail message sent, and list the names of the
recipients.<br><br>\n";

print "<u>Recipients:</u><br>";

&SendMail($mymsg);

print "<br><u>This is the message that was sent:</u><br><br>";
print "$mymsg\n";
print "</BODY>\n";
print "</HTML>\n";

sub SendMail($)
{

#txtmsg
my $txtmsg = shift;

# To and From email addresses
my $To = "blah\@blah.net";

my $from = "blah\@blah.net";
my $msg = new MIME::Lite
From =>$from,
To =>$To,
Subject =>'Some Stuff,
Type =>'text/html',
Data =>"$txtmsg";

$msg->send;
print "$To\n";
}
 
M

Mark Clements

mike said:
I have a basic script that has been rrrunning for years. All of a
sudden my users get 2 copies of each.

Here is my code below. I am getting 2 copies when this is executed.

Mike

#!/usr/bin/perl
#
# name of this program is: hb_mail_test.cgi
#
# this script automatically sends email just to (e-mail address removed)
#

use strict;
use MIME::Lite;

# The base path to the hbdata files
my $filebase = "/blah";

#The file being checked
my $file = "file.txt";

# The file fully qualified
my $selected = "$filebase/$file";

my $mymsg = "Hi this is Me!<br><br>";

#open the file and read it
open MAILFILE, "<$selected" or die "Cant open \n"; #open the file for

I take it that in production $selected is normally passed in via a form
submission. What happens if it is set to
"../../../../../../../etc/passwd" or similar? Even if it is a dropdown
box, it isn't safe.

&SendMail($mymsg);
<snip>

I can't see anything obviously wrong. It is possible that your mail
system is misconfigured and is doubling up mail messages. Check the
configuration of the MTA (probably sendmail) on the system on which the
script is running as a first port of call, then check its aliases (or
whatever files). Next check the configuration of the mail server that
the local MTA sends to etc.

Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top