I have set up postfix as a send-only mail server that does not relay, using this tutorial on Digital Ocean: https://www.digitalocean.com/community/tutorials/how-to-set-up-a-mail-relay-with-postfix-and-mailgun-on-ubuntu-16-04
Aside: it worked just fine with Ubuntu 18.0.4
This includes setup of mailgun.com for the sending service. My logs on the server show that I've sent the emails I'm sending, and MailGun's records (the UI is https://app.mailgun.com/app/sending/domains/mg.mydomain.com) also show that all mail is delivered.
Bottom line, it shows receipt in Outlook, but for now I need to specify it's not spam. That's fine, and appreciated.
But for Gmail, it doesn't even show up in spam. Just as if it was never sent on my end. I have a SPC and DKIM setup in the TXT DNS records. Can anyone tell me what the problem is, or how to resolve this?
-- EDIT --
Adding protonmail to the list of services where the email is sent (and not even treated as spam!)
OK, so an update from the initial post: I have discovered that sending from the mail
utility on the command line like this:
mail -s "Form Setup - Please Reply" [email protected] <<< "Hi John, please verify you have received this message and forward to [email protected] so I can check the receipt details. Call me if you have any questions at 512-xxx-xxxx"
Does not work. BUT, after installing PHP7.4 on the server and running this:
php -r "echo mail('[email protected]', 'PHP Install and Mail Successful', 'If I get this it means I am close to installing a solution for this. Call me at 12-xxx-xxxx to confirm this', 'From:[email protected]');"
Actually works! Not only does it get received, but it doesn't go to spam, AND I can use a "from" domain on another server that I manage. I'm obviously a bit cautious about that, but for whatever reason using PHP7.4 (which uses sendmail) seems to work perfectly.
One final thing, PHP info says I am using sendmail
vs. mail
:
~# php -i | grep mail
mail.add_x_header => Off => Off
mail.force_extra_parameters => no value => no value
mail.log => no value => no value
sendmail_from => no value => no value
sendmail_path => /usr/sbin/sendmail -t -i => /usr/sbin/sendmail -t -i
Path to sendmail => /usr/sbin/sendmail -t -i
MAIL => /var/mail/root
$_SERVER['MAIL'] => /var/mail/root