The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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 04:01 PM
AIX send mail with HTML message body and a binary attachment G-Man UNIX for Dummies Questions & Answers 4 03-22-2007 02:15 PM
sending mails with attachment and also some text in mail body guptan UNIX for Advanced & Expert Users 7 05-25-2006 06: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 09:07 PM
How to get åäö in e-mail message body de98luto UNIX for Dummies Questions & Answers 4 07-10-2002 05:35 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-28-2008
thumper thumper is offline VIP Member  
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
  #2 (permalink)  
Old 01-28-2008
KevinADC KevinADC is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2008
Posts: 731
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
  #3 (permalink)  
Old 01-28-2008
thumper thumper is offline VIP Member  
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
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 10:10 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0