• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 293
  • Last Modified:

Mail Questions

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.

  • 2
  • 2
  • 2
  • +2
1 Solution
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.

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
andrewmchorneyAuthor Commented:

Where is the local mqueue directory located? What is full path name?
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

andrewmchorneyAuthor Commented:
What is the difference between mail and mailx?
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.

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

To find it on your system, use find:

find / -name mqueue -ls

Regards, Nisus.
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.
Force-accepted by
CS Moderator
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

  • 2
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now