I’m having trouble setting up Gmail’s SMTP service to handle outgoing emails for my company domain techcorp.net. Every time I attempt to send a test message, I encounter connection issues.
Here’s what happens when I run the mail command:
admin@techcorp-server:/etc/postfix# echo "testing email delivery" | mail -s "test message" [email protected]
ERROR: hostname (techcorp-server) not fully qualified - check configuration
[email protected]... Attempting connection to [127.0.0.1] through relay...
[email protected]... Delayed: Connection rejected by [127.0.0.1]
I’ve been trying to get this working for hours but keep hitting the same roadblock. The system seems to be trying to connect locally instead of reaching out to Gmail’s servers. Has anyone successfully configured this type of setup before? Any guidance would be really helpful.
This is a pretty common issue when Postfix isn’t set up right for external SMTP relay. The system defaults to localhost because it doesn’t know how to reach Gmail’s servers. Here’s what you need to do: edit your Postfix main.cf file and set relayhost to smtp.gmail.com:587, then configure SASL authentication with your Gmail credentials. Make sure you’ve got the ca-certificates package installed for TLS verification. One thing I’ve noticed - sometimes you need to restart the Postfix service twice after making changes before they actually stick. The hostname problem should clear up once you get the relay configured properly.
sounds like a config issue. check that you’ve got smtp_use_tls=yes and smtp_sasl_auth_enable=yes in main.cf. both are needed for Gmail relay. also, use your app password instead of the usual Gmail password.
That error indicates Postfix is attempting local delivery rather than using Gmail’s SMTP servers. I faced a similar issue during a migration last year. It’s often due to a missing Postfix authentication configuration. You should create a password file with your Gmail app password and reference it in your main.cf. Additionally, ensure that your hostname resolution is functioning properly, as the ‘not fully qualified’ warning typically points to DNS issues that can hinder external relay connections. Also, verify that your firewall allows traffic through port 587, as Gmail requires access to this TLS submission port.