Discussion:
[gentoo-user] Help with local mail, please
(too old to reply)
Peter Humphrey
2024-02-13 16:00:02 UTC
Permalink
Hello list,

For years, I've been using postfix to accept mail from LAN hosts, and from the
Internet via my ISP. This has never worked as I want it - it's just so complex
to set up and understand. Well, it is for a bear of little brain like me.

Can someone tell me how to make postfix accept all mail addressed to any host
or user on the LAN - and not forward any mail to anywhere at all? It's running
on a single-homed host on the LAN, and all other hosts are also single homed.
Any of four hosts can originate mail, and I have fetchmail running on the same
host to collect POP3 mail from my ISP. Dovecot serves IMAP4 to KMail clients
on the LAN.

At present, postfix is insisting on forwarding mail addressed to root on a LAN
machine, but it's supposed to be acting on behalf of that machine. Two other
hosts' mails never show up anywhere.

Or perhaps there's a more suitable MTA out there?
--
Regards,
Peter.
Arve Barsnes
2024-02-13 17:30:01 UTC
Permalink
Post by Peter Humphrey
For years, I've been using postfix to accept mail from LAN hosts, and from the
Internet via my ISP. This has never worked as I want it - it's just so complex
to set up and understand. Well, it is for a bear of little brain like me.
Can someone tell me how to make postfix accept all mail addressed to any host
or user on the LAN - and not forward any mail to anywhere at all? It's running
on a single-homed host on the LAN, and all other hosts are also single homed.
Any of four hosts can originate mail, and I have fetchmail running on the same
host to collect POP3 mail from my ISP. Dovecot serves IMAP4 to KMail clients
on the LAN.
At present, postfix is insisting on forwarding mail addressed to root on a LAN
machine, but it's supposed to be acting on behalf of that machine. Two other
hosts' mails never show up anywhere.
I'm not sure I quite understood where you're having problems, but I
have a machine that accepts mail from the LAN through postfix, so I'll
show some of my setup. Replace any <> with your hostnames.

On the LAN machine I don't have postfix, I only send mail directly to
the machine with 'sendmail', but I found that I have in
/etc/mail/mailertable:
192.168. smtp:<mail machine hostname>
<mail machine hostname> esmtp:<mail machine hostname>
And in /etc/mail/local-host-names I have set <mail machine hostname> -
maybe that does something, but I send mail directly with sendmail
either way.

On the postfix machine I have in /etc/postfix/aliases:
root: arve
This should make all mail to root be delivered to me. It also contains
a bunch of aliases that I'm not sure if is necessary:
arve@<hostname> arve
arve@<hostname>.lan arve
arve@<hostname>.localdomain arve
arve@<other machine hostname>.lan arve

In /etc/postfix/main.cf there is this, and I assume at least some of
this makes this all work:
myhostname = <hostname>.lan
inet_interfaces = $myhostname, localhost
mydestination = $myhostname, localhost.$mydomain, localhost, <hostname>
mynetworks = 192.168.0.0/24, 127.0.0.0/8

Regards,
Arve
Peter Humphrey
2024-02-13 22:20:01 UTC
Permalink
Post by Arve Barsnes
I'm not sure I quite understood where you're having problems, but I
have a machine that accepts mail from the LAN through postfix, so I'll
show some of my setup. Replace any <> with your hostnames.
On the LAN machine I don't have postfix, I only send mail directly to
the machine with 'sendmail', but I found that I have in
192.168. smtp:<mail machine hostname>
<mail machine hostname> esmtp:<mail machine hostname>
And in /etc/mail/local-host-names I have set <mail machine hostname> -
maybe that does something, but I send mail directly with sendmail
either way.
I think those entries must be for sendmail.
Post by Arve Barsnes
root: arve
This should make all mail to root be delivered to me.
Yes, I have root: prh, but postfix still tries to forward mail for
I hadn't thought of doing that. When I tried it, postfix complained "Names must
Post by Arve Barsnes
In /etc/postfix/main.cf there is this, and I assume at least some of
myhostname = <hostname>.lan
inet_interfaces = $myhostname, localhost
mydestination = $myhostname, localhost.$mydomain, localhost, <hostname>
Isn't <hostname> the same as $myhostname?
Post by Arve Barsnes
mynetworks = 192.168.0.0/24, 127.0.0.0/8
I'll try setting mynetworks and see what happens.

Thanks, Arve.
--
Regards,
Peter.
Arve Barsnes
2024-02-13 22:40:01 UTC
Permalink
Post by Peter Humphrey
I think those entries must be for sendmail.
Yes, that machine has sendmail from mail-mta/opensmtpd, not postfix,
not sure it matters.
Post by Peter Humphrey
Post by Arve Barsnes
In /etc/postfix/main.cf there is this, and I assume at least some of
myhostname = <hostname>.lan
inet_interfaces = $myhostname, localhost
mydestination = $myhostname, localhost.$mydomain, localhost, <hostname>
Isn't <hostname> the same as $myhostname?
No, $myhostname is <hostname>.lan

Like you I've had some trouble in the past, so a lot of this is from
trying and failing, but it works as I want it now, so I'm happy-ish.

Regards,
Arve
J. Roeleveld
2024-02-14 11:40:01 UTC
Permalink
Post by Peter Humphrey
Hello list,
For years, I've been using postfix to accept mail from LAN hosts, and from
the Internet via my ISP. This has never worked as I want it - it's just so
complex to set up and understand. Well, it is for a bear of little brain
like me.
Can someone tell me how to make postfix accept all mail addressed to any
host or user on the LAN - and not forward any mail to anywhere at all? It's
running on a single-homed host on the LAN, and all other hosts are also
single homed. Any of four hosts can originate mail, and I have fetchmail
running on the same host to collect POP3 mail from my ISP. Dovecot serves
IMAP4 to KMail clients on the LAN.
At present, postfix is insisting on forwarding mail addressed to root on a
LAN machine, but it's supposed to be acting on behalf of that machine. Two
other hosts' mails never show up anywhere.
Or perhaps there's a more suitable MTA out there?
I've been using postfix for longer than I can remember.
The config entries I changed from default are:

--- main.cf ---
myhostname = <hostname.TLD>
mydomain = <TLD>
myorigin = <TLD>
mynetworks = <full list of local networks, ex. : 192.168.0.0/24,
192.168.1.0/24>
smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated,
reject_unauth_destination
-------

Also, are all emails sent to "mydomain" or do you have additional domains
configured?
If the latter, did you set "virtual_alias_domains = hash:/etc/postfix/
virtual_domains"
Include all virtual domains the file and converted the file to a .db ?

--
Joost
Peter Humphrey
2024-02-16 05:20:01 UTC
Permalink
Post by J. Roeleveld
I've been using postfix for longer than I can remember.
--- main.cf ---
myhostname = <hostname.TLD>
mydomain = <TLD>
myorigin = <TLD>
mynetworks = <full list of local networks, ex. : 192.168.0.0/24,
192.168.1.0/24>
That's helpful - thanks Joost.
Post by J. Roeleveld
smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated,
reject_unauth_destination
No relaying here; all outgoing mail goes to my ISP.
Post by J. Roeleveld
Also, are all emails sent to "mydomain" or do you have additional domains
configured?
If the latter, did you set "virtual_alias_domains = hash:/etc/postfix/
virtual_domains"
Include all virtual domains the file and converted the file to a .db ?
Just the one "mydomain"
--
Regards,
Peter.
Peter Humphrey
2024-02-16 15:50:01 UTC
Permalink
Post by Peter Humphrey
Post by J. Roeleveld
I've been using postfix for longer than I can remember.
--- main.cf ---
myhostname = <hostname.TLD>
mydomain = <TLD>
myorigin = <TLD>
mynetworks = <full list of local networks, ex. : 192.168.0.0/24,
192.168.1.0/24>
That's helpful - thanks Joost.
You're welcome. Was this enough to get it working?
I forgot to add that my system was already almost identical to yours, so I
don't know whether to say yes or no. :)
Post by Peter Humphrey
Post by J. Roeleveld
smtpd_relay_restrictions = permit_mynetworks,
permit_sasl_authenticated, reject_unauth_destination
Post by Peter Humphrey
No relaying here; all outgoing mail goes to my ISP.
If your mailserver (postfix) is sending emails to your ISP, that is (from
the viewpoint of postfix) relaying by definition.
Er... outgoing mail doens't go through postfix at all; it goes direct from my
KMail client to my ISP.
Post by Peter Humphrey
Post by J. Roeleveld
Also, are all emails sent to "mydomain" or do you have additional
domains configured?
If the latter, did you set "virtual_alias_domains = hash:/etc/postfix/
virtual_domains"
Include all virtual domains the file and converted the file to a .db ?
Just the one "mydomain"
...so no need to set any virtual domains.
If you have only 1 domain, keep that "virtual_alias_domains" empty.
No such setting in my main.cf so I assume it's empty.

Anyway, I looked at some of those mails that postfix was trying to forward, and
they were old and unimportant, so I purged them.

Let's see what other problems I've made for myself... :)
--
Regards,
Peter.
Loading...