checking the status of sendmail


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting checking the status of sendmail
# 1  
Old 02-15-2011
Java checking the status of sendmail

Hi All,

I like to check the status of sendmail and take the appropriate action based on success / failure etc.

I have gone through one of the thread where a suggestion is made to use RC for return code

Following is the code:
==================================
Code:
#!/usr/bin/bash
export MAILTO="xxx@yyy.zzz"
export LOGFILE="1.log"
export SUBJECT="Report"
export BODY="/devhome/tmanda/1.html"
export ATTACH1="/devhome/tmanda/coa.pdf"
export ATTACH1_NAME=${ATTACH1##*/}
echo "ATTACH1_NAME=$ATTACH1_NAME"
export ATTACH2="/devhome/tmanda/gatd.txt"
export ATTACH2_NAME=${ATTACH2##*/}
echo "ATTACH2_NAME=$ATTACH2_NAME"
(
 echo "To: $MAILTO"
 echo "Subject: $SUBJECT"
 echo "MIME-Version: 1.0"
 echo 'Content-Type: multipart/mixed; boundary="-q1w2e3r4t5"'
 echo
 echo '---q1w2e3r4t5'
 echo "Content-Type: text/html"
 echo "Content-Disposition: inline"
 echo
 cat $BODY
 echo
 echo '---q1w2e3r4t5'
 echo 'Content-Type: application; name="'${ATTACH1_NAME}'"'
 echo "Content-Transfer-Encoding: uuencode"
 echo 'Content-Disposition: attachment; filename="'${ATTACH1_NAME}'"'
 echo
 uuencode $ATTACH1 $ATTACH1
 echo
 echo '---q1w2e3r4t5'
 echo 'Content-Type: application; name="'${ATTACH2_NAME}'"'
 echo "Content-Transfer-Encoding: uuencode"
 echo 'Content-Disposition: attachment; filename="'${ATTACH2_NAME}'"'
 echo
 uuencode $ATTACH2 $ATTACH2
 echo
 echo '---q1w2e3r4t5--'
) | sendmail $MAILTO
RC=$?
echo "sendmail rc=$RC"

But, this is always returning 0 irrespective of To address is valid or invalid.
Is there a proper way of checking whether the mail is successfully sent or any error and then take an appropriate action.

Last edited by tmanda; 02-16-2011 at 12:39 AM.. Reason: code tags, obfuscated email
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

FIFO Status Checking/Running

May i please know 1) How to check if FIFO process is down? 2) How to bring FIFO up and running? we are using redhat Linux OS and bash shell Thank you. (1 Reply)
Discussion started by: Ariean
1 Replies

2. Shell Programming and Scripting

Script for SFTP Status Checking

Greetings... I have to construct shell script to check the SFTP status, Define a global variable (say sftpStatus). Set it to default value "success" when you define it first time outside the script. check the current SFTP status (say currentStatus - local variable within the script) if... (16 Replies)
Discussion started by: manju98458
16 Replies

3. Shell Programming and Scripting

Checking status of engines using C-shell

I am relatively new to scripting. I am trying to develop a script that will 1. Source an executable file as an argument to the script that sets up the environment 2. Run a command "stat" that gives the status of 5 Engines running on the system 3. Check the status of the 5 Engines as either... (0 Replies)
Discussion started by: paslas
0 Replies

4. Shell Programming and Scripting

Checking directory status

Can I use -ctime/-mtime to verify if a particular directory has been updated or not? I don't care about number of days. I just want to perform some operations only if the folder is modified (or it's metadata is modified), i.e. some files are added to the directory. This thread has a more... (1 Reply)
Discussion started by: Pramit
1 Replies

5. Shell Programming and Scripting

Checking the status of mail sent.

Hi, Is there any way to check the status of the mail sent or not.e.g mail -s "Error Message" abc@xyz.com <aaa/bbb/data.txt Can it return a status code which will confirm the delivery of mail sent?Please suggest. Thanks, Anil (1 Reply)
Discussion started by: anil029
1 Replies

6. Shell Programming and Scripting

how to know the mail sent status using sendmail

Hi, I am using sendmail command to send mail This is the command i am using cat <filename> | /usr/lib/sendmail -v <emailid> I will put the contents in the file as body of the email I want the subject also to be printed in the email I want to know whether email has been successfully... (1 Reply)
Discussion started by: trichyselva
1 Replies

7. Shell Programming and Scripting

Checking Status of PID

I'm developing a script that spawns many background processes that will be executing concurrently and need to check the exit status of each spawned process after it terminates. After starting the background process I can get the pid from $! which I can store in an associative array but how do I... (2 Replies)
Discussion started by: twk
2 Replies

8. UNIX for Dummies Questions & Answers

checking the status of file ftp

Hi, I m new to unix and I need a help in FTp-ing a file. My script is given below ftp -n <<END_SCRIPT open $FTP_HOST user $FTP_USER $FTP_PASSWD lcd $TEMPFOLDER cd $FTP_LOCATION put $1 bye END_SCRIPT exit_status=$? if ; then log "successfully FTPed the file" else... (5 Replies)
Discussion started by: MeeraNair
5 Replies

9. Shell Programming and Scripting

Checking Exit Status

I hope one of you smart people out there can help me with what seems like a real simple questing but I can't quite figure out. In a script I am doing a cmp on two files. I am trying to check the exit status with an if statement but can't seem to figure out the syntax. If the exit status is 1 I... (4 Replies)
Discussion started by: PrimeRibAndADew
4 Replies

10. UNIX for Dummies Questions & Answers

Sending mail, status checking

After I send a mail thr unix with following command uuencode tmpFile | mailx -s "sub1" emailid Yet, I havent received this mail at intended mail client. In order to find out if the sent mail action resulted in failure, I checked at /usr/spool/mail/userid But there also I couldnt find... (1 Reply)
Discussion started by: videsh77
1 Replies
Login or Register to Ask a Question