1

To clarify the intent of my question, let me make an analogy to the question "What is the simplest way to put data into a file?"

The usual way that GUI users will put data into a (new) file is to double click on a program icon, click the menu bar, click "new," click "save," click to choose a location for the file, type the name of the file, and click the "save" button.

The simplest way to put data into a file (from the command line) is: echo whatever > file


As I understand it, email addresses originally referred to actual usernames on machines and actual machine names. So if the IP of the machine you logged into (say, at a university) was 7.7.7.7, and if you logged in with the username pete, you could be reached by email sent to [email protected]. (Is that right?)

The point is that the email was directly associated with your user name and computer. Hence why an email I received from the command line of a server at work showed as sent from "[email protected]".

So, what is the minimal setup needed to send and receive email between two computers (directly to command line user accounts), with no third computer or Google server or MS Exchange or whatever else?

(For UNIX and Linux systems, obviously. Mostly interested in Linux, though if Mac is included that would be nice.)


Note: If there are a huge number of different ways to do it so this is "too broad," please help me edit the question. I'm not asking for software recommendations, I'm asking for how the parts fit together at the simplest level without proxies and relays and other complexities.


Edit: The answers so far are helpful but omit any details on how to receive the email. It seems that the Google search phrase I was missing is "minimal MTA Linux" but if anyone would like to answer more fully I would love it. (If not I'll have to work it out and eventually self-answer.) :)

4
  • Possibly useful: help.ubuntu.com/lts/serverguide/email-services.html
    – muru
    Commented Jun 21, 2017 at 5:59
  • Are the computers on the same local network, or do you have to go through the Internet? Commented Jun 22, 2017 at 23:09
  • @Gilles, this is a question for learning, so I can get enough data to set up a minimal testbed and closely inspect and better understand the mechanics of email—not a question about specific existing computers. So whichever is simpler. (Simplest to set up testbed-wise is two computers on the same local network e.g. home WiFi, but also with connection to the internet.)
    – Wildcard
    Commented Jun 22, 2017 at 23:17
  • "you could be reached by email sent to [email protected]. (Is that right?)" - not quite. Early remote mail was done over UUCP, so if your hostname was bigvax your email address would have been bigvax!pete. Unfortunately there wasn't a central database of hostnames so you had to provide a path that would tell the mailers how to get the message to you. Lots of history there - look up uucp bang paths Commented Jul 13, 2023 at 17:52

3 Answers 3

1

I'll assume that the two users and their two computers are independent, e.g. that user A can't simply access user B's computer and write files into the filesystem.

That means that the minimal config is one where A can connect to the MTA on B's machine, and the MTA considers itself responsible for email to B's machine/domain.

This means that when A says it has a message for B, the MTA takes responsibility for securing the message to B's mailbox.

Going down a level, this means:

  • A connects to the listener port of B's MTA (traditionally port TCP/25)
  • A identifies the sender and recipient, and B's MTA says ok
  • A passes the message, and B's MTA sends a response that indicates it takes responsibility
  • B's MTA then writes the message to disk (B's mailbox)

There are hacky ways past this, which I mention in passing. If A is root on B's machine, A can append a message directly to B's mailbox just by creating/editing a suitable file. For example by editing an mbox file. But that's a kinda pathological case.

1
  • This is the sort of overview I was looking for, thanks.
    – Wildcard
    Commented Jun 21, 2017 at 5:45
1

The simplest usual way to send mail between two computers is to have a "mail transfer agent" (MTA, program that accepts emails in SMTP format) run on the sending and receiving computer. Then you can run any command-line program on the sending computer that formats your mail to contact the sending MTA, and it will deliver it to the receiving MTA. For example

echo "This is a text" | mail -s "This is the subject"

is enough. There are various other programs to send/format/read mails.

In a pinch, you can contact the receiving MTA directly with telnet etc., as described in the other answer. This is more minimal, but I wouldn't call it "simpler".

1

If you just want to add software to both sender and receiver, then you need a DNS server also. MTA's needs that to send mail.

The setup is two servers on a closed net with no internet access. Here listed with hostnames (they are needed) and IP number. You can use any IP number.

7.7.7.7 foo.org
7.7.7.8 bar.org

On foo.org you have to install a DNS server (i.e. bind), and bar.org should use that. Both servers should have an MTA (postfix/exim4).

When configured, you can run this from bar.org:

john@bar:~$ date | mail -s Test [email protected]
2
  • Great. So is it also the MTA that says "you have new mail in (pathname)" on Pete's terminal? Or is that something else? (And it makes sense that DNS must be involved for the MX records, thanks!)
    – Wildcard
    Commented Jun 21, 2017 at 5:49
  • 1
    @Wildcard I think it is just the shell which is configured to look for new mail in /var/spool/mail/pete.
    – hschou
    Commented Jun 21, 2017 at 5:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .