0

I cant get a simple test message out of my Ubuntu VM to my gmail for reporting.

I've followed several guides to set up an App Password in /etc/postfix/sasl_passwd, using port 587, disabled firewall, etc..

I can get internal messages to /var/mail/root. The log at /var/log/mail.log shows status=bounced (unknown user: . I have a feeling its because my server doesnt have an external IP or domain. Yet it can access apt update fine. Do I have to expose the IP externally somehow? Is there anyway to send out an email through the NAT of my Host machine?

/etc/postfix/main.cf

mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128, xx.xx.xx.xx
...
relayhost = [smtp.gmail.com]:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
#smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt

/etc/postfix/sasl_passwd: [smtp.gmail.com]:587 xxxxx@gmail.com:xxxxxxx chmod 600 /etc/postfix/sasl_passwd

postmap /etc/postfix/sasl_passwd && systemctl reload postfix
mail xxx@gmail.com <<< "message"

I think I need to set to some IP: mynetworks =

dpkg-reconfigure postfix restarts the config wizard, and I read this "Mail is not delivered to external delivery agents as root." I wonder if I cant send it out as root.

Also, someone told me port 587 is blocked by many ISPs. I could test it with telnet my.domain 587, but I dont have a static IP or domain. I tried with my dynamic IP, but get "Connection timed out".

Guides:
https://www.systoolsgroup.com/add/postfix-to-gmail-account/ https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-postfix-on-ubuntu-20-04


I was able to get a message from my GCP instance. And the settings are basically the same. I think my ISP may be blocking port 587.

alchemy
  • 99
  • 4

1 Answers1

0

It turns out GMail was sending messages to Spam and Trash. I tried using SendGrid and got better error messages in the log file. After setting the From, was able to get a 250 Delivered, and then went looking inside GMail. Both SendGrid and GMail smtps work now.

mydestination =
myorigin = a
smtp_sasl_security_options = noanonymous

For mail utility, if a subject is used, the -c switch needs to be used like mail -s "Disk Space Alert Used: $CURRENT" -c $EMAIL $EMAIL <<< $(hostname -i; uname -a)

alchemy
  • 99
  • 4