perl/mail - inserting file text in message body


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perl/mail - inserting file text in message body
# 1  
Old 01-28-2008
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  
Old 01-28-2008
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  
Old 01-28-2008
Quote:
Originally Posted by KevinADC
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Solved] Cant get message body

Hi guys . I am trying to take the output of top command and mail it to myself . The code is : echo ############################################################## /usr/local/bin/top c n 1 b >> /export/home/top-output.txt echo ############################################################## ... (6 Replies)
Discussion started by: Junaid Subhani
6 Replies

2. Shell Programming and Scripting

mail: subject and body text

HI, After giving the mail -e name@domain.com its asking the subject : after this its enter in to the body of the mail i.e. (in edit mode) How to end this edit process to send mail ? (2 Replies)
Discussion started by: thelakbe
2 Replies

3. Shell Programming and Scripting

Not able to attach text in body of email while sending mail with attachment

Hi, We have been trying to send mail with attachment and it is going fine, but when we try to attach a text to the body of the email, we find that the mail is going fine with the body text but the attachment is not going through. We are using ksh. The command that is successfull without the... (6 Replies)
Discussion started by: jmathew99
6 Replies

4. Shell Programming and Scripting

Perl - Inserting text

Hey, I have 10 lines of text ... And I would like to Insert prefix for each line with static text. perl -pi -e 's/()/$1 TEST$./' data.txt Each line will have different static prefix, Code above works perfectly for 1st line ... I'm just not sure how I can run same command for 2nd line 3rd... (4 Replies)
Discussion started by: NDxiak
4 Replies

5. Shell Programming and Scripting

How to send a mail with attachement as well as message Body..?

Hi all, i am working with CSH, i want to know that how to send a mail in UNIX shell script (CSH) with attachment as well as message body. i know that how to send a mail with attachment and message body. but i want know both things in a single mail Suggession would be appreciate. ... (1 Reply)
Discussion started by: psiva_arul
1 Replies

6. AIX

Send mail attachments and have a mail body

Hi, How can I send mail attachments from shell script (AIX) and have a mail body as well ? Thanks in advance. (1 Reply)
Discussion started by: shibajighosh
1 Replies

7. UNIX for Dummies Questions & Answers

AIX send mail with HTML message body and a binary attachment

I'm trying to script sending an e-mail message on an AIX 5.x server with the following requirements: 1. command line switch to specify file name containing message body in HTML format 2. command line switch to specify file name of a binary attachment 3. command line or input file to specify... (4 Replies)
Discussion started by: G-Man
4 Replies

8. UNIX for Advanced & Expert Users

sending mails with attachment and also some text in mail body

Hi, Can some one help me with the syntax of the mailx that should send an attachment and also some text in the message body together. When I am using the following syntax it is not sending the attachment but only the message body. unix2dos -ascii $REPORTFILE | uuencode $PCFILE | mailx -s... (7 Replies)
Discussion started by: guptan
7 Replies

9. Shell Programming and Scripting

How can I write a HTML file in UNIX and sent it as a body of a mail

Hi, How can I write a HTML file in Unix. Once I do that, I want to send this file as a body of a mail, along with writing a subject for the mail I am sending through unix. How can that be done? (0 Replies)
Discussion started by: diwa81
0 Replies

10. UNIX for Dummies Questions & Answers

How to get åäö in e-mail message body

First of all: Hi all, i´m a new unix user and i´m swedish so please bare with me. When i generate an e-mail on a unix server and send it through novell netware 5, i loose the swedish characters å, ä and ö in the body of the message, however they remain in the subject row. What to do? Anyone?... (4 Replies)
Discussion started by: de98luto
4 Replies
Login or Register to Ask a Question