|Meet the Gang 1 2 3 4 5 6 7|
From Faber Fedor
Answered By John Karns, Mike "Iron" Orr, Mike Martin, Heather Stern, Ben Okopnik
A client of mine is discovering the Joy That Is Linux. He recently asked me if it was possible to send email from applications (written in JBASE, a PICK shell that runs on Linux). I mentioned that you could do this:
mail -s "Some Subject" firstname.lastname@example.org < output_from_app
and he was impressed. He has since come up with several time- and resource-savings applications of that simple redirection to the mail command.
He has raised an intersting (to me) question and although I can come up with two solutions, I'm looking for a better one. Also, it's generated a question that I can't answer, hence this posting.
The question is: How do you send mail between two linux boxen if there is no DNS server from which to query for an MX record?
Now, I'm not asking for the impossible here. The two boxen run sendmail/postfix and they are on the same internal network (the sender is 10.10.10.1 and the receiver is 10.10.10.2).
I could tell him to install a DNS server, which he would do (I love clients that listen to me but there should be a simpler solution. We could send the email to a local user on .1 and fetchmail the mail from .2, but that's too much of a kludge for my taste.
I've been through the HOWTOS and google and didn't find anything applicable (at this point Ben walks in, donning his mirrored sunglasses, executes a google search using 1.5 words (without quotes), finds The Canonical Page that answers this question and makes me look like a fool (again ).
[Ben] <mock growl> Don't do that, Faber; the fact that one of us has the answer _does not make the rest of us look like fools. Unproductive attitude there, sir. Me, I'm always happy when I see one of the other Gangsters come up with an answer to something I don't know (how d'you think I got this smart? - I get to learn stuff, which is a very good thing indeed.
[Heather] half a search word?
[Iron] mail email@example.com
Some mail transfer agents may balk at it, but I've found it to work most of the time.
[Heather] Works even better if the IP address is in brackets: firstname.lastname@example.org
[Mike] Also, you can put the domain names in the poor man's DNS: /etc/hosts.
[Mike Martin] Assuming that the network is small with no server (as implied) /etc/hosts is the right idea
If you are sending externally you would need a DNS either locally or via the isp anyway
[Ben] "/etc/hosts", or maybe even a lightweight local (caching?) DNS. I'm coming to really like PDNSD; painless to install, dirt-simple to set up. Or, you could always use "ssmtp" to rotate the mail off the local hosts to the actual MTA, since it's local; that's my solution (farm the job out to the guy who's good at it.)
[Heather] Yes, you can use /etc/hosts, but it can't do an MX record lookup. Your smtp daemon will need some tweaking. In sendmail you can tell it that transport for a given named host will go through an explicit IP address host, and then it would never try an MX lookup, just use the burned in route.
[John] Depending on the distro, distro version, and MTA you're using ...
Using SuSE 7.x & sendmail, and a psuedodomain I use, I've come up with the following solution to that problem:
edit /etc/mailertable to add entries like the following
mylinuxServer1.my.domain smtp:mylinuxServer1.my.domain mylinuxServer2.my.domain smtp:mylinuxServer2.my.domain
I don't have DNS setup, as the servers are isolated, but sendmail via dialup. I do have the hostnames listed in the hosts file on each server though. In this way, any mail addressed to user@mylinuxServer1.my.domain only goes out when connected to that server.
[Heather] The postfix equivalent to that is /etc/postfix/transports, although that's actually mentioned in /etc/postfix/main.cf to activate it, so you could name the file anything you like.
You can't use nullmailer for these even if it's only two boxes, because that won't accept mail for local deliveries. You could keep all the mail on only one of 'em and use nullmailer on the rest of the machines though. At that point the machine becomes a very tiny server and also needs to run a pop or IMAP daemon to allow mail pickup. At which point you may as well also set up a dummy local DNS, maybe for a silly domain name that won't be used by the outside world because there are no root servers for it, like fabershouse.local -- which would serve A and MX records for say... livingroom.fabershouse.local, den.fabershouse.local, etc.
You could skip mail and drop notes in a samba share at each other, or ssh in and share a kibitz session using your favorite text editor. Which means somebody becomes a server but may bother people a lot less.
|Meet the Gang 1 2 3 4 5 6 7|