Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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?
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
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…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

610 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