Mail Questions

Posted on 2001-06-15
Medium Priority
Last Modified: 2010-04-21
I working on a project that may in the C++ code, send a created email message through the mail command.. I have some questions.

The command format will be cat <filename>  | mail <email address>.

1. Is there a way to do a mail <address> <message>

2. Is there a way to determine that the user is a valid user?

3. Is it possible to determine if the mail command processed the request successfully and if it was not successful, how to determine what the error was.

4. Is it possible to determine if the system where the email is going received the email message?

5. Is it possible to determine if the person who is supposed to get the email actually got the email and read it.

The answers to the above question will aid in the decision regarding automatic email generation rather than doing manual email generation.

Question by:andrewmchorney
  • 2
  • 2
  • 2
  • +2
LVL 40

Accepted Solution

jlevie earned 400 total points
ID: 6197122
Taking the questions in order...

1) Not with any version of "mail" that I know of, but other mail clients may have that capability. However, you can always do "mail email-address <messgae-file".

2) In the general case, no. If the addresses were all local (within your domain) then it would be possible. However if the addresses are randomly distributed to Internet users there is no method(s) of verifying an address that will work in all cases.

3) The exit status of "mail email-address <message-file" will tell you if the email was accepted for delivery. That means that it has been passed from "mail" to the local Mail Transport Agent (MTA) for further processing. The MTA can only indicate any errors in delivery by sending a "bounce message" to the sender and there are a number of reasons that delivery can fail, such as: no such user at the remote server, no such domain or host, running afoul of anti-spam protection, user over quota, etc. And the bounce message won't necessarily happen immediately. If the email address looks valid (the domain exists and the remote SMTP server is in the DNS), but the remote SMTP server isn't accessible the MTA will continue delivery attempts for several days (typically 4-5 days) before giving up and "bouncing the message".

4) Maybe. If you have direct access to the local SMTP server and can check the logs you may be able to determine if specific messages have been delivered to the next hop on their path to the recipient. Note that knowing that your local SMTP server has passed the message "up the line" tells you nothing about utlimate delivery to the mail server that the adressee will get the message from. There can be one or more other MTA's in the path to the adressee.

5) The only way to determine if the recipient received and read the mail is to have some mechanism to "close the loop", like having them reply to the message or go to a web page and enter a unique value from the message. A "Return Receipt" can tell you that the email was delivered to the adressee's mail client, but you still don't know if it has been read. Also some folks (me included) disable all "Return Receipts" and in extreme cases they are blocked at the remote MTA.

Expert Comment

ID: 6199065

1. mailx -s "Subject" user@domain < standard_email

2. sendmail will certainly check that the domain that you are sending the email to is valid.  I think that it will attempt to verify the user as well.

3. The exit status of the mailx command is stored in $?.  Query this immediately after the mailx command.  It should be zero.

4. You can check the local mqueue directory to see if the email is still waiting to be forwarded, but it can stay there for up to five days.

5. I believe you can request a 'Read Receipt'.  This will prompt the user and they can choose not to.  I don't know how to do this in sendmail, but MS Exchange can do it.

Regards, Nisus

Author Comment

ID: 6203182

Where is the local mqueue directory located? What is full path name?
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Author Comment

ID: 6203441
What is the difference between mail and mailx?
LVL 40

Expert Comment

ID: 6207342
Where the mail work queue is located depends on what OS you are running. Most Unixen use /var/spool/mqueue, but the Mail Transport Agent (MTA) can be configured for a differnet location.

"mail" and "mailx" are just slightly different Mail User Agents (MUA's). Both do essentially the same thing and you typicall find one or the other on any given Unix. Dunno that I've used a Unix that had both. My recollection, hazy at best, is that "mailx" came out of the BSD world and that "mail" came from the SysV world.

Expert Comment

ID: 6210442

Under Solaris the mail queue is /var/spool/mqueue.

To find it on your system, use find:

find / -name mqueue -ls

Regards, Nisus.

Expert Comment

ID: 6877304
ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101 or Netminder will return to finalize these if still open in seven days.  Please post closing recommendations before that time.

Question(s) below appears to have been abandoned. Your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you. You must tell the participants why you wish to do this, and allow for Expert response.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question. Again, please comment to advise the other participants why you wish to do this.

For special handling needs, please post a zero point question in the link below and include the question QID/link(s) that it regards.
Please click the Help Desk link on the left for Member Guidelines, Member Agreement and the Question/Answer process.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Please click you Member Profile to view your question history and keep them all current with updates as the collaboration effort continues, to track all your open and locked questions at this site.  If you are an EE Pro user, use the Power Search option to find them.  Anytime you have questions which are LOCKED with a Proposed Answer but does not serve your needs, please reject it and add comments as to why.  In addition, when you do grade the question, if the grade is less than an A, please add a comment as to why.  This helps all involved, as well as future persons who may access this item in the future to seek help.

To view your open questions, please click the following link(s) and keep them all current with updates.

To view your locked questions, please click the following link(s) and evaluate the proposed answer.

------------>  EXPERTS:  Please leave any comments regarding your closing recommendations if this item remains inactive another seven (7) days.  Also, if you are interested in the cleanup effort, please click this link http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643

Moderators will finalize this question if still open in 7 days, by either moving this to the PAQ (Previously Asked Questions) at zero points, deleting it or awarding expert(s) when recommendations are made, or an independent determination can be made.  Expert input is always appreciated to determine the fair outcome.
Thank you everyone.
Moderator @ Experts Exchange

P.S.  For any year 2000 questions, special attention is needed to ensure the first correct response is awarded, since they are not in the comment date order, but rather in Member ID order.

Expert Comment

ID: 6973409
Force-accepted by
CS Moderator

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses
Course of the Month13 days, 11 hours left to enroll

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question