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
Veteran
Veteran


Joined: 07 Mar 2007
Posts: 1997

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: 6227
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
Veteran
Veteran


Joined: 24 Aug 2005
Posts: 1046

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
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3131

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
Veteran
Veteran


Joined: 07 Mar 2007
Posts: 1997

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: 1969

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
Veteran
Veteran


Joined: 24 Aug 2005
Posts: 1046

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
dmpogo
Advocate
Advocate


Joined: 02 Sep 2004
Posts: 3267
Location: Canada

PostPosted: Thu Dec 22, 2022 7:30 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
ian.au
Guru
Guru


Joined: 07 Apr 2011
Posts: 591
Location: Australia

PostPosted: Thu Dec 22, 2022 10:06 am    Post subject: Reply with quote

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

I'm guessing they resolved this one already? :D
Back to top
View user's profile Send private message
dmpogo
Advocate
Advocate


Joined: 02 Sep 2004
Posts: 3267
Location: Canada

PostPosted: Thu Dec 22, 2022 4:47 pm    Post subject: Reply with quote

ian.au wrote:
Quote:
Posted: Sun Jan 15, 2017 1:11 pm

I'm guessing they resolved this one already? :D


:D

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 :) Not that there was something there that I did not know already.
Back to top
View user's profile Send private message
Goverp
Veteran
Veteran


Joined: 07 Mar 2007
Posts: 1997

PostPosted: Fri Dec 23, 2022 10:33 am    Post subject: Reply with quote

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


Joined: 14 Jun 2007
Posts: 3339
Location: Rasi, Finland

PostPosted: Fri Dec 23, 2022 8:06 pm    Post subject: Reply with quote

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...
_________________
..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20067

PostPosted: Sat Dec 24, 2022 1:35 am    Post subject: Reply with quote

Mail processing model
_________________
Quis separabit? Quo animo?
Back to top
View user's profile Send private message
dmpogo
Advocate
Advocate


Joined: 02 Sep 2004
Posts: 3267
Location: Canada

PostPosted: Sun Dec 25, 2022 4:23 pm    Post subject: Reply with quote

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?

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


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


Joined: 15 Apr 2005
Posts: 916

PostPosted: Mon Jan 16, 2023 10:40 pm    Post subject: Reply with quote

I used to use nullmailer, but recently completely revamped my mutt setup because I found the builtin smtp quite slow. Replaced nullmailer with msmtp. While I'm quite familiar with postfix, I found it overkill for my purposes. msmtp does everything I need, it sends email for various addresses to the resp. providers' SMTP submission host, delivers root's cron email locally and also has a sendmail mode. A very nice feature is the "passwordeval" config option that allows you to have all your passwords (for SMTP) in encrypted files; if you use gpg, you can benefit from gpg-agent.

https://marlam.de/msmtp/
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