Setup CWP Postfix 3.4 SMTP Relay port 465 – December 2020

Published: December 2020

CWP = CentOS Web Panel

CentOS Version = 7

Postfix Version (bundled at the time of writing with CWP) = 3.4.7

SMTP Relay Port: 465 (Some services use 587. I have not tested this because my service uses 465.)

Hi, this isn’t a true setup guide as much as it is a “I just did this and this is the errors I had guide.”. If you have found this guide – then maybe you are searching for answers to the same problem? Let’s see.

1.) Here are the lines I modified in the /etc/postfix/main.conf file.

/etc/postfix/main.conf

#Make sure these files match the proper names in the directory.
smtpd_tls_key_file = /etc/pki/tls/private/hostname.csr
smtpd_tls_cert_file = /etc/pki/tls/certs/hostname.bundle

#Put your smtp relay followed by the port number (this line uses port 465 but some services use 587)
relayhost = smtp.example.com:465 

# enable SASL authentication
smtp_sasl_auth_enable = yes
# disallow methods that allow anonymous authentication.
smtp_sasl_security_options = noanonymous
# where to find sasl_passwd
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
# Enable STARTTLS encryption
smtp_use_tls = yes
# where to find CA certificates
smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt

smtp_tls_wrappermode = yes
smtp_tls_security_level = encrypt

*Don’t forget to save and restart postfix before testing changes.

2.) Create sasl_passwd hash file.

Create the file “sasl_passwd” in the /etc/postfix/ directory.

Add the following line to the file. Replace ‘smtp.example.com’ with the smtp relay server. Replace ‘username’ with the username your smtp relay service gave you. Replace ‘password’ with the password they gave you or you assigned at your smtp service.

smtp.example.com:465 username:password

Save and close the file.

Run the following command:

sudo postmap /etc/postfix/sasl_passwd 

This will hash your username and password.

Now run the following commands:

sudo chown root:root /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
sudo chmod 0600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db

This will protect the access permissions for the files you just created with your username and password.

*Don’t forget to save and restart postfix before testing changes.

3.) Install cyrus-sasl-plain

I did not find this in any guide. I just kept getting error messages and tracked them down to missing this. Run this in your CentOS terminal to install.

yum install cyrus-sasl-plain

*Don’t forget to save and restart postfix before testing changes.

Leave a comment

Your email address will not be published. Required fields are marked *