To send a mail through shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting To send a mail through shell script
# 1  
Old 09-19-2014
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.
Code:
mail id : upload.xxx@example.com

# 2  
Old 09-19-2014
Hello kannansoft1985,

Here is an example for same.
Code:
MAILFROM=Singhisking@test.com
MAILTO=Singhdaddy@test.com 
FILE=/singh/test/results_test.txt
cat - ${FILE} <<EOF | /usr/sbin/sendmail -oi -t
From: ${MAILFROM}
To: ${MAILTO}
Subject: $SUBJECT
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
MIME-Version: 1.0
EOF


Thanks,
R. Singh

Last edited by RavinderSingh13; 09-19-2014 at 04:32 AM..
# 3  
Old 09-19-2014
I tested to execute the below mail But the mail not sent , please check it
Code:
MAILTO=upload.xxx@example.com  
FILE=/root/msg.txt
cat - ${FILE} <<EOF | /usr/sbin/sendmail -oi -t 
From: ${MAILFROM} 
To: ${MAILTO} 
Subject: $SUBJECT 
Content-Type: text/html; charset=us-ascii 
Content-Transfer-Encoding: 7bit 
MIME-Version: 1.0 
EOF


# 4  
Old 09-19-2014
try
Code:
echo "Mail Body" | mailx -s "Hello Friends" upload.xxx@example.com

Or if you want to send file contents as mail body
Code:
mailx -s "Hello Friends" upload.xxx@example.com < file.log

# 5  
Old 09-19-2014
I try this both , But it's also not sent the mail to upload.xxx@example.com
Code:
echo "Mail Body" | mailx -s "Hello Friends" upload.xxx@example.com
 Or if you want to send file contents as mail body
Code:
mailx -s "Hello Friends" upload.xxx@example.com < file.log

# 6  
Old 09-19-2014
1) is upload.xxx@example.com exists?
2) is mail installed on your linux/unix box?
what is output of below commandwhich mail
# 7  
Old 09-19-2014
I am using Rehat version 4.4 operating system.
I am assigning mail name is another which is exist.
Pre-installed
output of which mail is /bin/mail

---------- Post updated at 04:10 PM ---------- Previous update was at 03:18 PM ----------

Is anyone know about troubleshooting the mail problem.Please help me to resolve this problem.

---------- Post updated at 04:32 PM ---------- Previous update was at 04:10 PM ----------

What are all the steps to be taken for troubleshooting the mail problem.

Last edited by kannansoft1985; 09-19-2014 at 06:53 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell script to send mail alert

Hi I have below shell script to send mail alert , however I want to add more functionality in this script and that is , script should only check that file between 9 am to 5pm , and if there is no activity in this time 9 am to 5 pm for 2hours then it should give me mail alert, please help... (2 Replies)
Discussion started by: scazed
2 Replies

2. UNIX for Beginners Questions & Answers

Shell script to compare text and send a mail

Hello, Somebody can help me to develop a script for the below requirement I have a 3 files in a directory which was dynamically changed everyday basis. I need a script to fetch the 1pattern of strings in each file. if the three matching pattern is same send a mail with subject as success else... (1 Reply)
Discussion started by: MATHANKUMAR
1 Replies

3. 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

4. Shell Programming and Scripting

Shell script to send mail alert

HI Guys, I am writing one shell script to send the mail alert to some email id's if the file not modified in last 10 mins but its not working, I believe MTIME is null string is wrong . can you please assist me on this. script :- filename="abc.txt" echo "Filename is $filename"... (1 Reply)
Discussion started by: abhigrkist
1 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

Looking for shell script to monitor CPU utilization and send mail once exceed 75%

Dear Group, I'm look for shell script to Monitor CPU usage and send mail once it exceed 75% I'm running Suse10.4. (3 Replies)
Discussion started by: clfever
3 Replies

7. UNIX for Advanced & Expert Users

Send a mail when a shell script is modified

I would like to know, whether is there any command/tool in Linux (something like Oracle Trigger function) to send a mail if a particular shell script has been modified with details like, modification time, modified by, etc. Thanking in advance, (1 Reply)
Discussion started by: apsprabhu
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

Send e-mail in Shell script

How to send an error mail from a shell script e.g. mail destination_adr@blabla.int "Message : here an error message " thanks, Ann. (1 Reply)
Discussion started by: annelisa
1 Replies
Login or Register to Ask a Question