I have GMail payed account for own company-like mail. The DNS server for record MX is set to Google servers. I have the same domain set for port 80 (HTTP, A record in DNS) for my home server (I have public IP and redirected port). It is Armbian on a Banana Pi. Everything is fine: I can send email from BPi via sendmail to any address and it appears as coming from root with my only public email at this domain (so rather from BPi than Google server). But the problem is that emails sent by PHP scripts on this home server are not arriving, as they arrive locally. What I am trying to do is to receive email from PHP script (any address, account) to my GMail email account in the same domain, but not on home server (BPi), I need it on my GMail server (to check it on smartphone). I can share logs and configuration data. The instruction I used is at this address.
Ok, so as I have gone through many webpages and tried many solutions for sendmail, I have found that for sendmail it is impossible to achieve what I wanted in this situation. Changing sendmail to postfix resolved the problem.