Shell Script To E-Mail


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell Script To E-Mail
# 8  
Old 11-16-2012
is your mutt supports -e then use it like below

Code:
mutt -e "my_hdr Content-Type: text/html" -s " System Status $DATE" -a $ATTACHMENT -- $MAILADDR < $SUBJECTFILE

# 9  
Old 11-16-2012
I not get this in my e-mail, but now no attachment.

Code:
--3V7upXqbjpZ4EhLz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, Attached is the current status of the System Kind Regards --3V7upXqbjpZ4EhLz Content-Type: text/html; charset=us-ascii Content-Disposition: attachment; filename="Status.html" --3V7upXqbjpZ4EhLz-- 

Does this mean that my mutt doesn't support -e? I did mutt --help and the -e was listed thoguh.
# 10  
Old 11-16-2012
# 11  
Old 11-16-2012
I look at all three those posts. It seems like I'm going round in circles. I again have it attaching the HTML file, but the HTML file is empty. If I jsut run it without doing a mailer, the correct information is displayed on the screen. The problem is actually geting the information display on screen into an e-mail and then sending it to the distribution list.

Code:
# ===================================================================== #
#     GATHERS AND DISPLAYS THE STATUS OF THE SYSTEM   #
# ===================================================================== #
function ATTACHMENT
{
cat "<<-Status
  <html>
  <head>
  <title>$TITLE</title>
  </head>
 
  <body>
  <h1>$TITLE</h1>
  <p></p>
  $(drive_space)
  $(backup_size)
  <body>
  </html>
Status"> $ATTACHMENT
}
# ===================================================================== #
#    GATHERS INFORMATION AND SEND MESSAGE ATTACHMENT    #
# ===================================================================== #
 
if [ "$MAILCONTENT" = "files" ]
 then
 mutt -e "set content_type=text/html" -s "System Status $DATE" -a $ATTACHMENT -- $MAILADDR <$SUBJECTFILE
fi
 
exit 0

# 12  
Old 11-16-2012
This:
Code:
Status"> $ATTACHMENT

Does not work. You need to redirect to a file on the first line of the here-document, for example:
Code:
cat <<-_Status_ > file

This User Gave Thanks to Scrutinizer For This Post:
# 13  
Old 11-16-2012
I really have no clue what I am doing wrong. I have now changed it and it nots creating an attachment anymore. I've read all the other forums and links and even went through a complete tutorial but I really have no clue what I am doing wrong.

Code:
function ATTACHMENT
{
cat <<-_Status_ > $ATTACHMENT
 
  <html>
  <head>
  <title>$TITLE</title>
  </head>
  <body>
  <h1>$TITLE</h1>
  <p></p>
  $drive_space
  $backup_size
  <body>
  </html>
_Status_
}
# ===================================================================== #
#    GATHERS INFORMATION AND SEND MESSAGE ATTACHMENT    #
# ===================================================================== #
 
if [ "$MAILCONTENT" = "files" ]
 then
 mutt -e "set content_type=text/html" -s "OTRS System Status $DATE" -a $ATTACHMENT -- $MAILADDR <$SUBJECTFILE
fi

Error messages
Status.html: No such file or directory
Status.html: unable to attach file.
# 14  
Old 11-16-2012
you need to call your function

Code:
 
_Status_
}
ATTACHMENT  #calling the function

This User Gave Thanks to itkamaraj For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

A shell script to run a script which don't get terminated and send a pattern from the output by mail

Hi Guys, I am very new to shell script and I need your help here to write a script. Actually, I have a script abc.sh which don't get terminated itself. So I need to design a script to run this script, save the output to a file, search for a given string in the output and if it exists send those... (11 Replies)
Discussion started by: Sambit Sahu
11 Replies

2. Shell Programming and Scripting

To send a mail through shell script

I want to send a mail through shell script,If it is possible Please give me a code. mail id : upload.xxx@example.com (8 Replies)
Discussion started by: kannansoft1985
8 Replies

3. Shell Programming and Scripting

Sending Mail via shell script

I am in need of a script that will send out emails while going through a NAT. What I have that works is as follows: display_remote_IP | sort | uniq | while read i do FOUND=0 for IP in `echo $ACCEPTABLEIP` do if ; then FOUND=1... (2 Replies)
Discussion started by: ldapguy
2 Replies

4. Shell Programming and Scripting

Sending mail from shell script

Hello All, I m trying to send mail from my unix script, I have used the below command mailx -s 'hi' email address < temp.txt It is not giving me any error,but I couldn't receive the mail Can you please help me. Many Thanks, Pragyan (6 Replies)
Discussion started by: prarat
6 Replies

5. UNIX for Dummies Questions & Answers

How to send e-mail from shell script ( C shell )?

Hi , How to send e-mail from shell script ( C shell ) . Mailx command is not working ( It didn't giving error also ). Please help me (2 Replies)
Discussion started by: arukuku
2 Replies

6. Shell Programming and Scripting

Mail shell script

Hi All, I want to send mail to multiple users.. Currently I am using below script cat $STATUS_FILE|mailx -s "$SUBJECT" -r xxx@yyy.com $MAILTO How can i give cc or bcc to in this script Please help me thanks in advance Regards RG (3 Replies)
Discussion started by: rgumm
3 Replies

7. Shell Programming and Scripting

sending a mail using shell script

Please help me in writing the script for sending an attachment through email.(For example my text file name is :abc.txt and it is in directory d:/abc) (1 Reply)
Discussion started by: anitha126
1 Replies

8. Shell Programming and Scripting

Shell script to send a mail

Hi , I need to prepare a script which will check my database with specific to particluar table. If the row count exceeds a certain limit, i need to send a mail to a set of Recipients. Being new to unix, please guide me to complete this task. Advance thanks, Sekar. (4 Replies)
Discussion started by: Sekar1
4 Replies

9. Shell Programming and Scripting

shell script to send a mail

Hi, I need a shell script which runs in the backround for all the 24 hours and send a mail to us regarding the output of the prstat command when the load average increase above certain percent. kindly help me on this...... (1 Reply)
Discussion started by: jayaramanit
1 Replies

10. Shell Programming and Scripting

Mail command in a shell script

i wanted to write a shell script that can automatically read unread mails and copy each one into a different file. I was trying to use the MAIL command to do it, but this command requires user input inbetween, I was wondering how that could be achieved in a shell script. Can sumone please suggest... (0 Replies)
Discussion started by: garric
0 Replies
Login or Register to Ask a Question