I've spent months trying to figure this out. I'm hoping someone here can help shed some light on what's happening.
So I have a mail server setup on my domain at mail.mydomain.vpn on a RaspPi3 running Raspbian-Buster; Postfix/Dovecot w/ Postgresql for tables like virtual users etc. It's been working great; it hosts a few mailboxes for my internal domain/vpn.
I have another box, box1.mydomain.vpn; also a RaspPi3 that I've setup to send cron job emails to an account (me@mydomain.vpn) hosted on mail.mydomain.vpn. It has postfix installed and configured to relay to mail.mydomain.vpn. Again, it works great.
Now I have my Slackware box (box2.mydomain.vpn). I also want to have cron job results emailed to me at the same address (me@mydomain.vpn) via a relay to mail.mydomain.vpn.
I added the same MAILTO=me@mydomain.vpn that I have on box1.mydomain.vpn to my crontab (for root).
I initially tried using sendmail on this box and spent time figuring out how to add my relay host and other configurations for it to send to mail.mydomain.vpn.
I came across some DNS issues; the MX for mydomain.vpn was pointing to the wrong IP for example.
I tried sendmail -bv
me@mydomain.vpn and it came back ok.
I try sending test messages via sendmail and they all appear in my
me@mydomain.vpn Inbox.
I then decided that maybe I needed to use postfix instead; it seemed to work on box1. So I switched over to Postfix, making sure to go through my main.cf and master.cf settings; encountering some issues with chrooting, etc. Seemed to get that all ironed out.
Despite all this, what seems to be happening based on what I'm seeing in my logs on mail.mydomain.vpn, is that sendmail/postfix does successfully connect, but for some reason with the crontab emails, it's being addressed to 'root@box2.mydomain.vpn' instead of 'me@mydomain.vpn'.
I recently combed through my postfix logs on mail.mydomain.vpn and noticed that the RCPT TO is set to
root@box2.mydomain.vpn; so it's definitely a case where cron is addressing the message to the wrong address.
But why? I have a feeling I've overlooked something that doesn't apply to Debian; I never had this problem getting this working on any of my Raspbian boxes.
Can anyone help me out?
Thanks!