I have some older code that was written for me some time ago. It used to work fine, but when I decided to use it again it's not putting the text file in the body of the message, it's sending it as an attachment. I'm able to run the mail command from command prompt and it works fine so I'm not sure what could be wrong with this code. Thanks for any help with this. This is the html form that sends the message.
<HTML><HEAD><TITLE>Email</TITLE> <META http-equiv=Content-Type content="text/html; charset=iso-8859-1"> <META content="MSHTML 5.50.4207.2601" name=GENERATOR></HEAD> <BODY text=#000000 bgColor=#ffffff> <FORM name=form1 action=/cgi-bin/smail.pl method=post> <TABLE width="86%" border=0> <TBODY> <TR> <TD bgColor=#66ccff><B>User Notices:</B></TD></TR> <TR> <TD bgColor=#cccccc><B>Message:</B><BR><TEXTAREA name=txtMessage rows= +15 cols=75> </TEXTAREA> </TD></TR></TBODY></TABLE> <TABLE width="86%" border=0> <TBODY> <TR> <TD bgColor=#cccccc><INPUT type=submit value="Send Emails" name=Subm +it> </TD></TR></TBODY></TABLE></FORM> <P>&nbsp;</P></BODY></HTML>
This is the perl code
#!/usr/bin/perl -U ############################################################### # # 2001 - smail.pl # Send message to all users of system # ############################################################### #to add users to which you do not wish to send emails, just add email +to the dat file (one username per line) $NoSendFile = "donotsend.dat"; $MessageFile = "noticemsg.txt"; $AddrBookFile = "noticemail.dat"; $mailprog = "mail"; # Get information from office ################################### read(STDIN,$in,$ENV{'CONTENT_LENGTH'}); $in =~ s/\+/ /g; $in =~ s/%([a-fA-F0-9][a-dA-F0-9])/pack("C",hex($1))/eg; # Create a new record ######################################### $ParName = "txtMessage"; $ParTrailer = "&Submit=Send Emails"; if (index($in, $ParName) >= 0) { $MessageText = substr($in, index($in, $ParName) + length($ParName) + + 1); $MessageText = substr($MessageText, 0, rindex($MessageText, $ParTr +ailer)); } # Append Message to file ####################################### open(MESSAGE, ">$MessageFile") || die OnError($MessageFile); print MESSAGE $MessageText; print MESSAGE "\n"; close(MESSAGE); # Send message to each address book entry ###################### open RECIPIENT, $AddrBookFile || die OnError($AddrBookFile); open (FH, "$NoSendFile") || die OnError($NoSendFile); @nosendusers = <FH>; close(FH); foreach $nosenduser(@nosendusers) { chop ($nosenduser); } SendPageHeader(); # Open file of users not to send to ############################ while (<RECIPIENT>) { $sendto = $_; $sendto =~ s/\n//g; $sendto =~ s/ //g; $send = 0; foreach $nosenduser(@nosendusers) { if ($sendto eq $nosenduser) { $send = 1; } } if ($send eq 0) { ($sec,$min,$hour,$mday,$mon,$year,$wday,$isdst)= localtime(time); if (length($min) == 1) { $min = "0" . $min } if (length($sec) == 1) { $sec = "0" . $sec } $year += 1900; $mon += 1; $time = $mon . "/" . $mday . "/" . $year . " at " . $hour . ":" +; $time .= $min . ":" . $sec; $subject = "New Announcement"; $commandLine = $mailprog . " -s \"" . $subject . "\" " . $sendto; $commandLine .= " < " . $MessageFile; system ($commandLine); AppendUserToPage($sendto, $time); sleep 5; } } SendPageTrailer(); close RECIPIENT; # SemdPageHeader Method ####################################### sub SendPageHeader { # print "HTTP/1.0 200 OK\n"; print "Content-Type: text/html\n\n"; print "<html><title>Send Message Report</title><body>"; print "The message: <BR><BR>"; $MessageText =~ s/\n/<BR>/g; print $MessageText; print "<BR><BR> was sent to:<BR><BR>"; } # SendPageTrailer Method ###################################### sub SendPageTrailer { print "</body></html>\n"; } # AppendUserToPage Method ##################################### sub AppendUserToPage # AppendUserToPage(username, time) { my $username = shift(@_); my $currtime = shift(@_); print "<B> " . $username . " on " . $currtime . "</B><BR>"; } # OnError Method ############################################## sub OnError # OnError(filename) { my $FileName = shift(@_); # print "HTTP/1.0 200 OK\n"; print "Content-Type: text/html\n\n"; print "<html><title>Send Message Report</title><body>"; print "<P> This script has been unable to open the following file: + "; print $FileName . " </P>"; print "<P> Please make sure the file is not locked by another reso +urce "; print "and try again.</P>"; print " </BODY> </HTML>"; }

In reply to Text file not in body of messag by brosskgm

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.