To set up SMTP Relay in the CWP (CentOS Web Panel), follow these steps:
Steps to Configure SMTP Relay in CWP
1. Log in to CWP Admin Panel
- Go to your CWP admin URL:
http://<your-server-ip>:2030
- Log in with your root credentials.
2. Access Mail Server Manager
- On the left-hand menu, go to Email → MailServer Manager.
3. Configure Postfix for External SMTP Relay
- CWP uses Postfix as its mail server by default, so you’ll need to configure Postfix to relay emails through an external SMTP server.
4. Edit the Postfix Configuration
- Under MailServer Manager, click on Postfix Manager.
- Click on Main Configuration to edit the main configuration file.
5. Modify Postfix to Use External SMTP Relay
Add the following lines to the Postfix configuration:
bash
relayhost = [smtp.your-provider.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = may
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
smtp_use_tls = yes
- Replace
smtp.your-provider.com
with your SMTP provider (e.g.,smtp.gmail.com
for Gmail orsmtp.office365.com
for Office365). - Set the correct port (
587
for STARTTLS,465
for SSL, or25
for non-secured).
6. Create SASL Password File
-
Now, you need to store the SMTP authentication credentials in a file called
sasl_passwd
. -
Open the file in a text editor:
bashvi /etc/postfix/sasl_passwd
-
Add the following line with your SMTP provider credentials:
bash[smtp.your-provider.com]:587 username:password
Replace
username
with your email address andpassword
with your SMTP password.
7. Set Permissions and Hash the Password File
-
Set proper permissions to secure the file:
bashchmod 600 /etc/postfix/sasl_passwd
-
Hash the
sasl_passwd
file to create a.db
file that Postfix can use:bashpostmap /etc/postfix/sasl_passwd
8. Restart Postfix
-
After making these changes, restart the Postfix service for the configuration to take effect:
bashsystemctl restart postfix
9. Configure SPF, DKIM, and DMARC Records (Optional but Recommended)
- To avoid emails being marked as spam, add SPF, DKIM, and DMARC records in your DNS settings for the domain.
- You can use the CWP panel to set up SPF and DKIM under Email → MailServer Settings.
10. Test the Setup
- Send a test email to ensure the relay is working properly.
- You can use the CWP Roundcube mail client or configure an external mail client like Thunderbird or Outlook to test the relay.