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
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....
This is from my sendmail manual, although yours might be different:
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:
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.
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.
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.
$ 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.
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.