Using sendmail 2 copies get sent to each user

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

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.


# name of this program is: hb_mail_test.cgi
#    this script automatically sends email just to

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

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

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


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

sub SendMail($)

    my $txtmsg = shift;

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

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

    print "$To\n";

Re: Using sendmail 2 copies get sent to each user

mike wrote:

Quoted text here. Click to load it

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.


Quoted text here. Click to load it

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.


Re: Using sendmail 2 copies get sent to each user

No $selected is hardcoded in the script and not passed from anywhere

Site Timeline