It is a normal practice to receive incoming mail. However, the outgoing messages get stuck in the queue.
Need to configure Postfix on the Plesk server on Google Cloud? We can help you
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform related Google Cloud queries.
In this context, we shall look into how we can add Postfix on the Plesk server on Google Cloud.
To configure sending emails, we need to use one of the following solutions:
By default, Google Compute Engine blocks the SMTP ports, 25, 465, and 587. It does not allow outbound connections on them.
In such a case, Instances can receive emails. However, it does not allow sending emails from these ports.
1. Initially, we connect to the server via SSH.
2. Then we define the MTA on the server and switch to Postfix if necessary.
3. Later, we create a backup of the original /etc/postfix/main.cf configuration file and open it in a text editor:
# cp -a /etc/postfix/main.cf{,.original}
# vi /etc/postfix/main.cf
4. Adjust it in accordance with the Google documentation instructions.
Then we check if the following parameters exist and comment them out by adding a hashtag sign to its beginning:
default_transport = error
relay_transport = error
Comment it out like this:
#default_transport = error
#relay_transport = error
We add the SendGrid SMTP service as relayhost:
relayhost = [smtp.sendgrid.net]:2525
Here, we use port 2525 because Compute Engine does not allow outbound connections on ports 25, 587.
Then we add the following lines at the end of the file:
smtp_tls_security_level = encrypt
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
header_size_limit = 4096000
smtp_sasl_security_options = noanonymous
Once we set the parameters, we ensure that there are no duplicate directives that can break the configuration:
# cat /etc/postfix/main.cf | grep
"relayhost\|smtp_tls_security_level\|smtp_sasl_auth_enable\|smtp_sasl_password_maps\|header_size_limit\|smtp_sasl_security_options"
In case we find any, we comment out/remove them.
Then we generate the SASL password map:
# echo [smtp.sendgrid.net]:2525 yourSendGridUsername:yourSendGridPassword >> /etc/postfix/sasl_passwd
We use the postmap utility to generate a .db file:
# postmap /etc/postfix/sasl_passwd
We can verify the creation of the .db file using:
# ls -l /etc/postfix/sasl_passwd*
-rw——- 1 root root … /etc/postfix/sasl_passwd
-rw——- 1 root root … /etc/postfix/sasl_passwd.db
To set the proper permissions on .db file, we run:
# chmod 600 /etc/postfix/sasl_passwd.db
Then we remove the file containing SendGrid credentials:
# rm /etc/postfix/sasl_passwd
Finally, we reload the Postfix service to apply changes:
# service postfix restart
This article covers how to configure Postfix on the Plesk server on Google Cloud.
Note: any customization made in Postfix configuration can be overwritten by Plesk update (for example, in case of bug fix, when configuration files are updated), Plesk upgrade or by mchk utility, which resets default mail server configuration.