The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Attaching file and sending text in body using sendmail command!! sparan_peddu Shell Programming and Scripting 1 03-24-2008 12:01 PM
AIX send mail with HTML message body and a binary attachment G-Man UNIX for Dummies Questions & Answers 4 03-22-2007 10:15 AM
sending mails with attachment and also some text in mail body guptan UNIX for Advanced & Expert Users 7 05-25-2006 03:17 AM
How can I write a HTML file in UNIX and sent it as a body of a mail diwa81 Shell Programming and Scripting 0 10-13-2004 06:07 PM
How to get åäö in e-mail message body de98luto UNIX for Dummies Questions & Answers 4 07-10-2002 02:35 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-28-2008
Supporter
 

Join Date: Feb 2005
Posts: 49
perl/mail - inserting file text in message body

I've got the following code

sub mail_report {
$Mailer = '/usr/sbin/sendmail joe@somewhere.net';
open MAIL,"|$Mailer";
print MAIL "Subject: $X connection attempt \n";
open MESSAGE, "<$outdir$X";
print MESSAGE '$outdir$X\n';
close MESSAGE;
close MAIL;
} #End sub mail_report

where I would like to insert text from a file as the body of the message at the line
print MESSAGE '$outdir$X\n';
The message is received OK however the text is not inserted into the body of the message.
Could someone point out the error of my ways?
Thanks
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 01-28-2008
Registered User
 

Join Date: Jan 2008
Posts: 294
Code:
sub mail_report {
   $Mailer = '/usr/sbin/sendmail joe@somewhere.net';
   open MAIL,"|$Mailer";
   print MAIL "Subject: $X connection attempt \n\n";#two newlines after subject
   open(MESSAGE, "<", "$outdir$X") or die "$!";
   print MAIL <MESSAGE>;
   close MESSAGE;
   close MAIL;
} #End sub mail_report
some mails servers and mail clients will reject emails with no "from" header
Reply With Quote
  #3 (permalink)  
Old 01-28-2008
Supporter
 

Join Date: Feb 2005
Posts: 49
Quote:
Originally Posted by KevinADC View Post
Code:
sub mail_report {
   $Mailer = '/usr/sbin/sendmail joe@somewhere.net';
   open MAIL,"|$Mailer";
   print MAIL "Subject: $X connection attempt \n\n";#two newlines after subject
   open(MESSAGE, "<", "$outdir$X") or die "$!";
   print MAIL <MESSAGE>;
   close MESSAGE;
   close MAIL;
} #End sub mail_report
some mails servers and mail clients will reject emails with no "from" header
Thanks KevinADC
That fixed the problem.
thumper
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:55 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0