EXIT STATUS on mailx/sendmail

Tags
beginners, sendmail

 

 
Thread Tools Search this Thread
# 1  
Old 08-14-2006
EXIT STATUS on mailx/sendmail

Hi there

I am using mailx command to send mails. I want to send some important files to team members and wud like to know if the team member has recd my email or not.
How can I achieve this ?
Currently my piece of code is
Code:
uuencode ${FILE_NAME} ${FILE_NAME} >> mail_msg.txt
mailx -s"test phyo attachement" amra@yahoo.com < mail_msg.txt

Can anyone help please....????
Also is their any simpler alternative to this issue ?
I read the sendmail manual...and understand that it provides an EXIT_STATUS.
How to handle this EXIT STATUS ? What is -N DNS option ? Can someone explain? But then with SendMail I cannot include the Subject ??? It is importtant that I have a subject line ..for me the Subject Line will conatin some important info....
Please help.....
# 2  
Old 08-14-2006
This is from my sendmail manual, although yours might be different:
Code:
DESCRIPTION
...
       Sendmail  is not intended as a user interface routine; other programs provide user-
       friendly front ends; sendmail is used only to deliver pre-formatted messages.

Email is actually sent as text, so the subject field is just a line in the email header that starts with:
"Subject: "
I don't know that it's possible to tell if a message has actually been delivered or not. The receiving system would somehow have to communicate to your system that it did ( or did not ) receive the message.
# 3  
Old 08-14-2006
Please post in an appropriate technical forum, the "Post Here to Contact Site Administrators and Moderators" is for account problems and similar topics.

I am moving the thread to a more appropriate forum.
# 4  
Old 08-14-2006
HI Nathan

Is there any method where I can understand if the mail was sent succesfully or not ? This is becoz if the mail has not reached the user in first attempt I have to resend the email after 2 days ? Hence I need something like a log...
ALSO ...when I was going thru the Manual for sendmail ...I came across this info..hence wanted to know how to put it to use ?
-----------------------------Extracted from man Sendmail
The sendmail command returns exit status values. These exit values are defined
in the /usr/include/sysexits.h file. The following table summarizes the meanings
of these return values:

EX_CANTCREAT The sendmail command cannot create a file that the user specified.

EX_CONFIG An error was found in the format of the configuration file.

EX_DATAERR The input data was incorrect in some way.

EX_IOERR An error occurred during I/O.

EX_NOHOST The sendmail command could not recognize the specified host name.

EX_NOINPUT An input file (not a system file) did not exist or was not readable.

EX_NOPERM The user does not have permission to perform the requested operation.

EX_NOUSER The sendmail command could not recognize a specified user ID.

EX_OK The sendmail command successfully completed.
-----------------------------
Something like holding the return values ..in C..?? To create my own error log?
If I can in some way create an ErrorLog for Sent Emails...then my issue is solved....Can u guide me???

And yes ur right...
The sendmail command is not intended as a user interface routine; other commands provide user-friendly interfaces. Use the sendmail command only to deliver preformatted messages.



Thanks and Regards
Amruta Pitkar
# 5  
Old 08-14-2006
You cannot use sendmail to determine if the user received the email. You can determine if the sendmail command completed successfully. The return values, for example, EX_CANTCREAT, are integer values. These are defined in /usr/include/sysexits.h.

So when you run sendmail, capture the exit code. ( "$?" is the shell variable for the exit code ). Map the numeric error code to the textual description.
Code:
$ grep \#define /usr/include/sysexits.h
#define _SYSEXITS_H 1
#define EX_OK           0       /* successful termination */
#define EX__BASE        64      /* base value for error messages */
#define EX_USAGE        64      /* command line usage error */
#define EX_DATAERR      65      /* data format error */
#define EX_NOINPUT      66      /* cannot open input */
#define EX_NOUSER       67      /* addressee unknown */
#define EX_NOHOST       68      /* host name unknown */
#define EX_UNAVAILABLE  69      /* service unavailable */
#define EX_SOFTWARE     70      /* internal software error */
#define EX_OSERR        71      /* system error (e.g., can't fork) */
#define EX_OSFILE       72      /* critical OS file missing */
#define EX_CANTCREAT    73      /* can't create (user) output file */
#define EX_IOERR        74      /* input/output error */
#define EX_TEMPFAIL     75      /* temp failure; user is invited to retry */
#define EX_PROTOCOL     76      /* remote error in protocol */
#define EX_NOPERM       77      /* permission denied */
#define EX_CONFIG       78      /* configuration error */
#define EX__MAX 78      /* maximum listed value */

As far as the error log resolving your issue, I wouldn't depend on it. Maybe the users you are trying to reach have a machine that is down, or the mail delivery agent is broken on that machine. You have no way of knowing if it was delivered.

If you do want to create an error log, I recommend a shell script. Right after your "sendmail" command, capture the return code and log it.
Code:
sendmail;RC=$?
echo "sendmail rc=$RC" >> $LOGFILE

# 6  
Old 08-14-2006
thanks

Hi there

Thanks a lot....Atleast at this point just creating an Error File using the EXIT STATUS wud be great and sufficient.
I have tried some of the EXIT_STATUS and will now enhance the code to check for more return codes.
BTW, I am a C Programmer...but have to work a lot in Unix at this new work place due to the existing environment.
Can u suggest me a book or URL ....sort of tutorial to learn how to Shell Script. Like getting return codes, or conditional programming etc...something for a beginner ?
Thanks a lot Nathan.

-Regards
Amruta Pitkar
 

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Similar Threads More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Exit status in the script Raj999 Shell Programming and Scripting 2 01-07-2016 12:39 AM
Want to get the exit status paddu Shell Programming and Scripting 3 05-21-2013 07:18 AM
Exit Status smkremer Shell Programming and Scripting 2 03-28-2012 04:40 PM
How to exit from mailx kasparov Shell Programming and Scripting 2 11-18-2011 07:25 PM
Processes and exit status messi777 UNIX for Dummies Questions & Answers 7 07-07-2011 04:45 PM
Exit status redirection agent001 Shell Programming and Scripting 4 07-28-2010 10:21 AM
Exit status of grep prasbala Shell Programming and Scripting 7 03-09-2010 06:36 AM
$? = Exit status variable dummydba UNIX for Dummies Questions & Answers 4 01-22-2009 08:39 AM
Exit status MartyIX Shell Programming and Scripting 9 09-09-2008 06:47 AM
How to get the exit status yhacks Shell Programming and Scripting 1 05-19-2008 09:06 AM
exit status conditions sdcoms UNIX for Dummies Questions & Answers 6 05-16-2007 11:40 AM
Problem with exit status diganta Shell Programming and Scripting 1 09-28-2005 09:34 AM
exit status moxxx68 Shell Programming and Scripting 1 12-04-2004 07:27 PM
tar exit status thorndike UNIX for Dummies Questions & Answers 3 01-22-2002 04:39 PM
ftp exit status. oracle8 UNIX for Advanced & Expert Users 1 10-22-2001 12:34 AM
All times are GMT -4. The time now is 09:57 PM.

Unix & Linux Forums Content Copyright 1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password





Not a Forum Member?
Forgot Password?