EXIT STATUS on mailx/sendmail


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers EXIT STATUS on mailx/sendmail
# 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
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Mailx , sendmail and mailhost

Hi all, I am trying to grasp the concept between the 3 entity above. I understand that mailx - MUA I also understand that sendmail = MTA 1) If I have a centralized mail server (which might not be sendmail), can I just set mailhost in "/etc/hosts" to point to that mailserver and use... (7 Replies)
Discussion started by: javanoob
7 Replies

2. Shell Programming and Scripting

Want to get the exit status

Hi All, I am trying to create a zip file with all the txt files(these are in large number) in the current directory. I am able to do this operation sucessfully. After this i want to get the status of the tar command executed and do accordingly. When i am trying with the below code, the status... (3 Replies)
Discussion started by: paddu
3 Replies

3. UNIX for Dummies Questions & Answers

how to sendmail using mailx in linux

how to sendmail to other computer in the same computer lab using mailx? (8 Replies)
Discussion started by: help me
8 Replies

4. Shell Programming and Scripting

Exit Status

I have a shell script (#!/bin/sh) that interacts with Appworx and Banner Admin. In my script I want to check the exit status of awrun before continuing. awrun can run for 10 seconds or it can run for over a minute. So my question is, will it go through my if statement before awrun may even be... (2 Replies)
Discussion started by: smkremer
2 Replies

5. Shell Programming and Scripting

How to exit from mailx

Hello Guys, I have created function which is as follow: My function is working, but it's waiting after executing mailx command. If user will press Ctrl+d then only it is executing subsequent lines. I treid couple of options such as quit, exit, ., ETO, but it's not working. Is any one can help me?... (2 Replies)
Discussion started by: kasparov
2 Replies

6. Solaris

Configure mailx or sendmail

hi, I would like to configure mailx or sendmail to send out some mails to some users. I tried searching online for the configuration but it was kinda confusing. I thought that posting here might get someone to work with me step by step I tried sending out mail but i did not receive in my... (4 Replies)
Discussion started by: cghcgh
4 Replies

7. UNIX for Dummies Questions & Answers

Sendmail? Mailx? SMTP?

We require e-mails to come from one of our Solaris 10 boxes ASAP and have found that when using such things as Sendmail and Mailx all the mail goes to a Q that only fires every 15 minutes. We have tried everything we could think of to adjust this to force the Q to go every 1 minute but so far no... (3 Replies)
Discussion started by: LRoberts
3 Replies

8. Shell Programming and Scripting

Exit status

I'm preparing for exam and one of exams is to write own test command... I wonder if in unix is a command which just returns exit code you specify.. I know I can easily write a function like this: exStatus() { return $1 } -> my question is rather theoretical thank you! (9 Replies)
Discussion started by: MartyIX
9 Replies

9. Shell Programming and Scripting

How to get the exit status

Hi all, I'm running a program which return 1 upon success. But when encounters problem shell return 's '1' . How to differentiate between them the shell return value and script return value. Ex. function fn return '1' if executed successfully and '0' if failed. But when if shell encounters... (1 Reply)
Discussion started by: yhacks
1 Replies

10. Shell Programming and Scripting

exit status

i downloaded a text file from metalab.unc.edu called sh.txt and in this reference manual it refers to shell scripting exit status .. at the end of one of the examples that author gave an exit status of 127.. to what does a 127 exit status refer too and what is its purpose in the code. moxxx68 (1 Reply)
Discussion started by: moxxx68
1 Replies
Login or Register to Ask a Question