08-23-2012
6,384,
2,214
Join Date: May 2005
Last Activity: 28 October 2019, 4:59 PM EDT
Location: In the leftmost byte of /dev/kmem
Posts: 6,384
Thanks Given: 143
Thanked 2,214 Times in 1,548 Posts
Looks like you don't understand how mail (the system - not the command) works. Here is a very stripped-down (and inclomplete) explanation:
The backbone of the whole mail business is the "MTA", short for "Mail Transfer Agent". Think of its operation similar to what routers do to network packets: they have some rules which sorts of mails to send where and the rest is tossed to some default destination which hopefully can do something about these. On the other side of these connections there are similar MTAs, which pick up the received mails and either deliver them locally or again send them to other such MTAs, and so on and so on. This means that all these MTAs have to adhere to a "common language" to understand each other and in fact they do: they all use a certain special network protocol, called SMTP (Simple Mail Transfer Protocol), which is used to transport mails around. Examples for such MTAs would be "sendmail" or "postfix" or "exim", but also "Microsoft Exchange Server", albeit the latter should be taken with a grain of salt, because it does not adhere to all the accepted internet standards (see the RFCs 822, 1123, 1893, 2476, etc., etc.).
Now, this describes how mails are shuffled around, but what has to happen to originate/deliver a mail?
Well, on the other side of this backbone structure we have user programs - "mail" and "mailx" being two of them, but also "Mozilla Thunderbird" or other elaborate programs. More precisely these are called "MUA"s, "Mail User Agent"s.
So that leaves us with the last part - how do MTAs and MUAs interact?
We have already seen how the MTA acts on the outside, maintaining connections to other MTAs. "On the inside", that is: on the local system it runs at, it maintains queues for a all the mail users it knows to be local. Any mail directed at such a local user will not be sent outside by the MTA, but delivered locally. Because the MTA is a "daemon" (a process which runs all the time in the background) it will maintain these queues permanently. Usually these are not more than files in "/var/spool/mail" or "/var/mail" or a similar directory.
Most shells have provisions for regularly checking these queues for new entries. The Korn shell (ksh) and the Bourne again shell (bash) for instance have the system variables "MAIL", "MAILCHECK" and "MAILPATH", in other shells there are similar provisions.
The shell now checks in given intervals (MAILCHECK is a number of seconds, which sets the frequency) if the queue file has changed, which would mean arrival of new mail and then displays a configurable mail message (usually "You have new mail." or something similar). The user now can start his MUA, which pulls the messages out of the queue and into a privately maintained mail file (usually in the users home directory). Graphical email clients like Thunderbird tend to do this in the background because they are permanently open, but they wouldn't need to be, as much as e-mail as a system is concerned.
If a mail is written the MUA will send it to the MTAs outgoing queue, from where the MTA will pick it up and ... see above. In this regard, basic programs like "mail" and feature-rich email-clients like Thunderbird are alike.
Finally, to answer your original question:
You write a mail. "mailx" puts it into the outgoing queue of some MTA, which takes it from there and sends it to another MTA, which delivers it to the incoming mail queue of its local user, from where the users MUA picks it up and displays it. As the MTA on your side seems to be correctly configured (otherwise it wouldn't have been able to deliver your mail first) the recipient of your mail can employ the same way to answer you back.
I hope this helps.
bakunin
Last edited by bakunin; 08-23-2012 at 06:20 AM..