# Local mail without MTA

## Goverp

This seems to be asked regularly, so my apologies if it's been sufficiently answered before; of course I think it hasn't.

My use case:

Various daemons, such as smartd running on one Gentoo desktop machine, that want to send emails to advise of problems.  I use KDE kmail2 for email.  I want to get the daemon mail even if my Internet is down.

IIUC, and I think I don't, mailx should be able to do this, all by itself, or at least it should be possible for the daemons to be configured to mail to "admin" userid, without any MTA such as sendmail or postfix.  As the mail's not leaving the box, there should be no need for even a thin MTA such as ssmtp.  (at the moment I have ssmtp set to route the main to my ISP's SMTP server, which gets the mail to me, but only if the Internet is up.  nullmailer may be better, as it appears to queue the mail until the internet comes back, but why should I wait).

Again, IIUC, mailx should put the mail into /var/spool/mail/admin (a.k.a. /var/mail/admin), and that should be configurable as a kmail2 "account" for receiving mail.

However, mailx has a dependency on virtual/mta, so I can't actually configure this.  I may be getting confused between mail-mta/sendmail and the sendmail program provided by various MTAs (such as postfix, ssmtp, sendmail), so is there supposed to be a default sendmail program to do local mail, and is it necessary for mailx to operate?

Advanced use case:

As above, but several linux boxes on my local network 192.168.1.0/24 connecting via my router.  (Aside: the router has a firewall, and I've no incoming ports open to the outside world (unless it's been hacked).)  Would like daemon email to end up in my desktop mailbox, even if my ADSL line is dead but my router is alive.

This version seems to require an MTA, but I really don't need sendmail or postfix, just a simple process to relay the stuff from the source box over the local network to my desktop.  The simplest solution may be Gnu mailutils (net-mail/mailutils), which has the advantage of offering maildir support in its clients.  It seems to have a lot of USE flags that I'd hope to switch off for this use case (databases, security etc).  The mailutils documentation suggests this might not be as simple as I'd hoped.  Maybe the other boxes need ssmtp or nullmailer.

The basic trouble is that the use cases are simple, but the common solutions seem way to complex because they address too many irrelevant use cases.  I (and I expect others) would be grateful if someone can help me see the wood for the trees.

----------

## khayyam

 *Goverp wrote:*   

> IIUC, and I think I don't, mailx should be able to do this, all by itself, or at least it should be possible for the daemons to be configured to mail to "admin" userid, without any MTA such as sendmail or postfix.  As the mail's not leaving the box, there should be no need for even a thin MTA such as ssmtp.  (at the moment I have ssmtp set to route the main to my ISP's SMTP server, which gets the mail to me, but only if the Internet is up.  nullmailer may be better, as it appears to queue the mail until the internet comes back, but why should I wait).

 

Goverp ... mail/mailx doesn't do that :) .... its a MUA (mail user agent) not a MTA. The fact that delivery is local doesn't matter, the method, and requirements, are the same (that is how internet protocols scale) ... SMTP is a protocol, and so to do 'transport' you need an MTA. There are probably various perl, ruby, python, modules for mail transfer, but these are going to be fail more complex to use than nullmailer, or ssmtp.

 *Goverp wrote:*   

> Again, IIUC, mailx should put the mail into /var/spool/mail/admin (a.k.a. /var/mail/admin), and that should be configurable as a kmail2 "account" for receiving mail.

 

It's not an MTA, it expects to connect to an MTA to do 'transfer'. An MTA (supporting /etc/mail/aliases) can be configured to deliver such mail to whatever account you so choose. 

 *Goverp wrote:*   

> However, mailx has a dependency on virtual/mta, so I can't actually configure this.  I may be getting confused between mail-mta/sendmail and the sendmail program provided by various MTAs (such as postfix, ssmtp, sendmail), so is there supposed to be a default sendmail program to do local mail, and is it necessary for mailx to operate?

 

MTA's will have a /usr/sbin/sendmail so as to provide any MUA that command, the daemon (such as /usr/libexec/postfix/master) is another matter:

```
Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address       Foreign Address     State   PID/Program name

tcp        0      0 127.0.0.2:53        0.0.0.0:*           LISTEN  25942/dnscrypt-prox

tcp        0      0 127.0.0.1:25        0.0.0.0:*           LISTEN  1713/master
```

 *Goverp wrote:*   

> Advanced use case:
> 
> As above, but several linux boxes on my local network 192.168.1.0/24 connecting via my router.  (Aside: the router has a firewall, and I've no incoming ports open to the outside world (unless it's been hacked).)  Would like daemon email to end up in my desktop mailbox, even if my ADSL line is dead but my router is alive.

 

As long as there is a local network then mail can be delivered, even if "offline" (meaning there is no network connectivity for that host) then mail can be deferred until such a time as the network is available. What happens beyond the host, or the local network, isn't something you need to consider.

 *Goverp wrote:*   

> This version seems to require an MTA, but I really don't need sendmail or postfix, just a simple process to relay the stuff from the source box over the local network to my desktop.  The simplest solution may be Gnu mailutils (net-mail/mailutils), which has the advantage of offering maildir support in its clients.  It seems to have a lot of USE flags that I'd hope to switch off for this use case (databases, security etc).  The mailutils documentation suggests this might not be as simple as I'd hoped.  Maybe the other boxes need ssmtp or nullmailer.

 

You could use nullmailer, or ssmtp, for this, these are designed as 'simple' mail transfers ... however, I wouldn't rule out a more developed MTA (such as postfix, qmail, or what-have-you) as they more offer features (such as delivery deferral, etc) that might prove more flexible (ie, I assume your desktop isn't on 24/7 what happens to the mail when "source box" can't deliver, or its not connected to the network?). ssmtp and nullmailer are 'simple' MTA's they are designed to hand off mail to a mail hub and that's about it ... more complex scenario's require a more complex MTA. 

 *Goverp wrote:*   

> The basic trouble is that the use cases are simple, but the common solutions seem way to complex because they address too many irrelevant use cases.  I (and I expect others) would be grateful if someone can help me see the wood for the trees.

 

Having an MTA needn't be as though you're running a fully fledged server (on each machine) it can be non-exposed (see the above netstat output), lightweight, etc, but still provide additional features not included in the likes of ssmtp, or nullmailer. For the "advanced use case" above then I can't see you doing without a proper MTA, if this were my own local network then I would probably configure postfix (or qmail) on each host, and so avoid there being a requirement for a mail hub, I get the impression your objection really comes down to "why do I need a full blown mail server, when all I have is a few hosts/mails", and in a way that hesitancy is understandable, but on the other hand properly configured this is a one time fire and forget and should operate (and provide for all features/concerns) without too much fuss or bother, its the implementation that is key.

best ... khay

----------

## cboldt

I'll add that I like exim as a lightweight MTA, having used ssmtp and nullmailer for the same function.

----------

## szatox

Nullmailer doesn't let you receive emails. It's sender-only program.

I've been looking for some agent that would let me receive emails from my daemons too. I tried some tricks with nullmailer etc, and then I trashed it all and installed postfix. Being local-only is irrelevant. Nothing forces you to announce your email server and expose it. You can just as well keep it private, behind firewall, or bound to 127.0.0.1

----------

## Goverp

Thanks for the explanations guys.  I'll have to either install one of the real MTAs, or write my own.

I've realized there's a problem with MTAs restricted to the local network (in my case three boxes, a couple of desktops and a netbook attached to a router); both the MTA and the sender or recipient need to be on at the same time, and I normally only use one of the boxes at a time.

So what I want is an MTA in my router.  Which is interesting, 'cos I was thinking of cobbling something thin together with scripts and FTP to move files from maildir to maildir; and my router can run an FTP service.  Or maybe I just go back to nullmailer/ssmtp and send everything to my  mailbox on my ISP's email system.

----------

## cwr

Again for exim - it seems the best compromise for a local MTA.

Wlll

----------

## cboldt

If you run an MTA (other than ssmpt or nullmailer), it will hold mail that it can't deliver.  This happens to me when I take the laptop on the road.  When I get back to my LAN, it is not unusual for the laptop to have accumulated a queue of undeliverable mail relating to system cronjobs.

Just saying, after you set things up correctly, it won't matter if the receiving machine is up or down (my laptop away is like my mail server on the LAN being down), the emails will be sent eventually.

----------

## Ji.M

how about using 'procmail -d?

```

jim@gucky ~ % /usr/bin/procmail -d jim <<EOD

From: jim@gucky

Subject: test

test

.

EOD

jim@gucky ~ % la /var/spool/mail 

insgesamt 4

0 drwxrwsr-t 1 root mail 56 15. Jan 23:51 ./

0 drwxr-xr-x 1 root root 34 12. Jan 20:40 ../

4 -rw------- 1 jim  mail 74 15. Jan 23:51 jim

0 -rw-r--r-- 1 root root  0 12. Jan 20:40 .keep_net-mail_mailbase-0

jim@gucky ~ % cat /var/spool/mail/jim 

From jim  Sun Jan 15 23:51:21 2017

From: jim@gucky

Subject: test

test

.

```

It just came up to my mind. Combined with some good old fashioned UUCP it's probably what you want.

Greetings, Jirka

----------

## dmpogo

Among MTA's  that satisfy virtual/mta  on Gentoo,  there is esmtp.     It is no longer maintained, however it has an option force_mda,  which make it essentially a local to one machine email service.

Every mail send anywhere is delivered to the local MDA,  such as procmail.

That does not solve your extended problem of local network, but should solve the need for mail services getting emails from daemons locally on one computer

----------

## ian.au

 *Quote:*   

> Posted: Sun Jan 15, 2017 1:11 pm

 

I'm guessing they resolved this one already?  :Very Happy: 

----------

## dmpogo

 *ian.au wrote:*   

>  *Quote:*   Posted: Sun Jan 15, 2017 1:11 pm 
> 
> I'm guessing they resolved this one already? 

 

 :Very Happy: 

How did I get to see that old threat ?   Oh well, I was actually looking to solve exact same problem  for myself after finding that

5 years of emails from my backup server are still in nullmailer queue not going anywhere  :Smile:   Not that there was something there that I did not know already.

----------

## Goverp

FWIW, I went with opensmtp.  It's reasonably lightweight and easy to configure.  I put one MTA on each box, and checked I could send mail round the network.

----------

## Zucca

I would like to set up something like this, but I've never installed anything more than some smtp command line mail sender. That alone requires receiving mail server.

Then there's MDA which stands for Mail Delivery Agent?

And MTA? Mail Transfer Agent?

Oh well. Until I start up my new home server...

----------

## pjp

Mail processing model

----------

## dmpogo

 *Zucca wrote:*   

> I would like to set up something like this, but I've never installed anything more than some smtp command line mail sender. That alone requires receiving mail server.
> 
> Then there's MDA which stands for Mail Delivery Agent?
> 
> And MTA? Mail Transfer Agent?
> ...

 

MTA is that your command line sender. Basically, from senders perspective,  MTA is what provides /usr/sbin/sendmail,  it does not have to be run as a daemon.

On a receiving remote machine MTA  has to be probably run as a daemon, listening to incoming mails on some port.

MDA is, for instance,  procmail that will put mail locally to standard mbox's or maildir's.  But something has to feed it a mail.  Or receiving MTA itself can serve as MDA, perhaps with more limited capabilities.

In the model where sender and receiver is the same machine (as for instance just getting emails from daemons on the same machine),  sending MTA may not need to have receiving MTA (depending on implementation). For instance, sending esmtp, which I started using now,

can be configured to just pass the mail to local MDA, such as procmail.   So combination of esmtp/procmail  does local job, without having to run any MTA as a daemon.    My, for instance backup, daemon will just call esmtp-provided /usr/sbin/sendmail, which then passes mail to procmail for local sorting.   Real sendmail MTA can also be configured like that, but I did not find a way to have this configuration with nullmailer.    Most relay-like MTA's like nullmailer just want to push mail to some receiving MTA,  which is becoming an overkill for one machine setup.

I wonder if daemons can be configured to directly use procmail rather than sendmail, but I suspect that will depend on individual daemon, while all of them that can provide mail out capabilities do work with /usr/sbin/sendmail

----------

