Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Local mail without MTA
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Goverp
l33t
l33t


Joined: 07 Mar 2007
Posts: 639

PostPosted: Fri Jan 13, 2017 8:22 pm    Post subject: Local mail without MTA Reply with quote

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.
_________________
Greybeard
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Fri Jan 13, 2017 9:49 pm    Post subject: Re: Local mail without MTA Reply with quote

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:

netstat -tlnp:
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
Back to top
View user's profile Send private message
cboldt
l33t
l33t


Joined: 24 Aug 2005
Posts: 829

PostPosted: Fri Jan 13, 2017 10:13 pm    Post subject: Reply with quote

I'll add that I like exim as a lightweight MTA, having used ssmtp and nullmailer for the same function.
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1717

PostPosted: Sat Jan 14, 2017 12:39 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Goverp
l33t
l33t


Joined: 07 Mar 2007
Posts: 639

PostPosted: Sun Jan 15, 2017 10:55 am    Post subject: Reply with quote

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.
_________________
Greybeard
Back to top
View user's profile Send private message
cwr
Veteran
Veteran


Joined: 17 Dec 2005
Posts: 1968

PostPosted: Sun Jan 15, 2017 2:20 pm    Post subject: Reply with quote

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

Wlll
Back to top
View user's profile Send private message
cboldt
l33t
l33t


Joined: 24 Aug 2005
Posts: 829

PostPosted: Sun Jan 15, 2017 6:17 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Ji.M
n00b
n00b


Joined: 15 Jan 2017
Posts: 2

PostPosted: Sun Jan 15, 2017 11:11 pm    Post subject: Reply with quote

how about using 'procmail -d?

Code:

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
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum