castletonroad
Posts: 135
Joined: Sat Jul 25, 2015 11:23 pm

postfix for send-only on local network

Sun Dec 22, 2019 7:06 am

Hi,

I have three raspberry Pi machines running on my network :
192.168.0.1 (router/gateway)
192.168.0.24 (raspberrypi4)
192.168.0.22 (raspberrypi3)
192.168.0.20 (raspberrypi2)

On each machine, /etc/mailname = /etc/hostname = raspberrypi2/3/4

raspberrypi4 runs my postfix/dovecot mail server, and I have a static IP from my ISP with correctly established A/MX/TXT records etc. pointing to MYDOMAIN.ORG. All of the required ports on my router are correctly forwarded to raspberrypi4. This all works fine with no issues whatsoever.

The relevant section of raspberrypi4's main.cf is as follows:

Code: Select all

.
.
.
myhostname = MYDOMAIN.ORG
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = raspberrypi4
mydestination = $myhostname, MAIL.MYDOMAIN.ORG, raspberrypi4, localhost.localdomain, localhost
relayhost = 
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
message_size_limit = 0
virtual_mailbox_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
.
.
.
raspberrypi3 and raspberrypi2 both need to be able to send me emails, e.g. from running their cron jobs. I have installed postfix on both machines, but I cannot for the life of me correctly configure their main.cf files so that raspberrypi4 accepts their emails.

Please could someone give me some pointers on what their main.cf files should look like?

Thanks very much :)
Raspberry Pi 4 Model B | Raspberry Pi 3 Model B | Raspberry Pi 2 Model B

castletonroad
Posts: 135
Joined: Sat Jul 25, 2015 11:23 pm

Re: postfix for send-only on local network

Mon Dec 23, 2019 7:50 pm

OK, maybe I can put the problem more simply.

I have three raspberrypi machines sat behind a router/gateway.

#1 is a postfix mail server, #2 and #3 are not and instead run other tasks.

How do I configure #2 and #3 to send me emails (and without being rejected by #1’s strict postfix EHLO/HELO etc. configuration)?

Thanks very much.
Raspberry Pi 4 Model B | Raspberry Pi 3 Model B | Raspberry Pi 2 Model B

bls
Posts: 642
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA
Contact: Twitter

Re: postfix for send-only on local network

Mon Dec 23, 2019 9:26 pm

Not really an RPi specific problem. See http://www.postfix.org/postconf.5.html#mynetworks.
Pi tools:
RPi SD Card Image Manager: https://github.com/gitbls/sdm
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo
Easy VPN installer/manager: https://github.com/gitbls/pistrong
DNS/DHCP manager:https://github.com/gitbls/ndm

castletonroad
Posts: 135
Joined: Sat Jul 25, 2015 11:23 pm

Re: postfix for send-only on local network

Wed Dec 25, 2019 7:58 pm

Not an RPi specific problem, agreed, but I'm not a member of any other forums to ask for help on... ;)

I worked out the solution myself as:

1. On RPi4, add my network (192.168.0.0/24) to /etc/postfix/main.cf at the 'mynetworks = ' parameter
2. Create a domain for my LAN behind my router, and add this domain to the hosts files of each RPi, e.g. for RPi4:

Code: Select all

127.0.0.1       localhost
::1             localhost ip6-localhost ip6-loopback
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters
127.0.1.1       raspberrypi4.local.mynetwork.org raspberrypi4
192.168.0.22    raspberrypi2.local.mynetwork.org raspberrypi2
192.168.0.23    raspberrypi3.local.mynetwork.org raspberrypi3
192.168.0.24    raspberrypi4.local.mynetwork.org raspberrypi4
3. Then configure /etc/postfix/main.cf on RPI2 and RPI3 as, e.g. for RPi3:

Code: Select all

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = raspberrypi3.local.mynetwork.org
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, raspberrypi3.local.mynetwork.org, localhost.local.mynetwork.org, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = ipv4
4. Then configure /etc/aliases on RPi2 and RPi3 with appropriate entries to email my RPi4 email server:*

Code: Select all

root: postmaster@mynetwork.org
postmaster: postmaster@mynetwork.org
4. On RPi2 and RPi3 run 'sudo newalises' and 'sudo service postfix restart'

*I've not yet been able to deliver mail *within* the LAN (local.mynetwork.org) hence I send emails 'externally'.
Raspberry Pi 4 Model B | Raspberry Pi 3 Model B | Raspberry Pi 2 Model B

Return to “Networking and servers”