Author Topic: ISP or Server Provider Blocks Email Port 25. How to Configure CWP Outgoing Email  (Read 10735 times)

0 Members and 1 Guest are viewing this topic.


This is a Tutorial. Not a question. But before I get there I want to say something...

I spent so much time trying to figure out how to resolve the problem. This problem is when your dedicated or VPS servers blocks port 25.

The CentOS Web Panel team create this amazing Web Panel, which I love to use the most compare to any other other web panels.

What I don't understand is why they failed to provide support or create a working tutorial so everyone to benefit from because CWP utilize postfix as a mail server.

Their main tutorial blog doesn't work. What a failed! But I can't really blame CWP for this as postfix is also a standalone email server.
This article should be taken down because it is not complete or confusing, or perhaps it should be fixed:
The third party smtp relay service does not even give us their SMTP IP address since they use a proxy. I think that tutorial only works if you own another mailserver that does not has port 25 blocked.

Because it does not work. If it works, not a lot of people will come here seeking answers for the same problem.

Here are the list of topics that simply does not work:

The only topic I see that work is this one:
Thank you very much!

My method is a bit different.

Here are example of topics people try to get it solve, yet no solutions. Sad... CWP team can't help them or provide a working tutorial:

Here's the main tutorial:

Take a look at the following two photos

Photo 1:

Photo 2:

There are many email ports, but not all of them are the same. You can't simply replace their job.

Common Email Submission Ports are: 587, 465, 2525
The Only Email Relaying Port is: 25
Common Email Receiving Ports are: 143, 993, 110, 995

Now, many people are trying to solve this problem ask how to change replace port 25 with another port! That is not possible. The only port that is used between one MailServer to another MailServer is port 25. It means that you can't set one your EmailServer to send an email to another EmailServer on the interent with another port. There is no exception. So please do not ask how to replace Port 25 with another port.

Ports: 587, 465, and 2525 are use to submit email. It means that it is the port that use in the connection between your PHONE, Personal Computer, Email Clients, to the MailServer.

And port 143, 993, 110, 995 are use for receiving email. But this topic is not about receiving email. It is about sending emails.

The only way to solve this problem is to use a third party SMTP relay service such as Sendgrid, Pepipost, MailGun, etc...
Or simply just use another server that allows port 25.

Let's assume you can't really use any server that allows port 25. That's what this tutorial is for.

Use third Party Relay Service.

Once you set up an account with the third party service, add and verify all domain names that you use in your Centos Web Panel (CWP).

**Verifying domain means you setup the TXT records at your Domain's DNS registrar or CWP DNS Zone config to verify it.**

Once you've verified all domains,
you should obtain the SMTP server credentials.

The SMTP server credentials look like this:

SMTP Host:
SMTP Protocol: TLS or SSL or Plain
SMTP Port: 587 or 465 or 2525 (Note, if they provide 25, don't use it, since your server provider blocked it)
SMTP Username: YourUsername
SMTP Password: YourPassword

Once you've done that. Do these steps:

Step 1
Make sure the SASL authentication framework, and mailx are all installed.

Login to your server Terminal as root.

And run the following command:
Code: [Select]
# yum -y install cyrus-sasl-plain mailx

Step 2

In /etc/postfix/ , Add the following lines
Code: [Select]
smtp_sasl_security_options = noanonymous
smtp_sender_dependent_authentication = yes
sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relay
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
header_size_limit = 4096000

Step 3

Create a file call sender_relay at /etc/postfix/

The path to that file should be /etc/postfix/sender_relay

In /etc/postfix/sender_relay, add domains that must go through a relay along with the smtp server and port that was provided to me.

For example, if I have the following domains:

The SMTP server provided to me was with port 587

I will add the following:
Code: [Select]    

Make sure the @ is added in the front of each domain for this step.
Just to be clear, the is actually the server provided to you by the third party SMTP relay service such as example.
For example, Mailgun use and port 587  <-- you put that as

Step 4
In /etc/postfix/sasl_passwd

provide credentials to the smtp server that listed in /etc/postfix/sender_relay

In this step, provide your SMTP server relay credentials at /etc/postfix/sasl_passwd

Code: [Select]   YourUsername:YourPassword

Note that and YourUsername and YourPassword is provided to you by the third SMTP relay service such as Sendgrid, Mailgun, pepipost, etc..

Step 5

Runs the following commands in your server terminals:

Code: [Select]
# postmap sasl_passwd sender_relay
# postfix reload

Step 6
Now you can flush the email queue (attempt to deliver the previous emails).
Code: [Select]
# postqueue -f

At this point, it should work. If it does not work, please try to troubleshoot it with the following instructions below

If you counter any problems, try these troubleshoots:

The maillog can be reviewed if the test message is not successfully delivered. Open another shell and run tail while performing another test.
Code: [Select]
tail -f /var/log/maillog

If there are not enough details in the maillog to determine the problem, then the debug level can be increased by adding the following lines to the /etc/postfix/

Code: [Select]

The Postfix configuration must be reloaded after updating the file.
Code: [Select]
systemctl reload postfix

Remember to remove the debug settings when testing is complete. The verbose logs can have a negative impact on server performance.

Optional Steps:
Access to the sasl_passwd files should be restricted. ( If needed )

Code: [Select]
# chown root:postfix /etc/postfix/sasl_passwd*
# chmod 640 /etc/postfix/sasl_passwd*


Code: [Select]
# chmod 600 sasl_passwd
# chown root:root sasl_passwd

I will keep an eye on this topic just in case you guys are still needing help.
« Last Edit: January 19, 2021, 09:53:58 AM by beedno »

hi, thanks a lot, i got a step with your instructions, i just have one problem.

When I send a mail it is sent from the mail configured in /etc/postfix/sender_relay instead of the, I don't know why

Thank you very much in advance

hi, thanks a lot, i got a step with your instructions, i just have one problem.

When I send a mail it is sent from the mail configured in /etc/postfix/sender_relay instead of the, I don't know why

Thank you very much in advance


Iím glad at least the email works for you.
Did you add that domain in the list of your email domain?

Also, if you receive email using gmail, gmail will tell your where it is being relayed, which is the main domain of your server.

I have the same problem as you but my ISP doesn't block port 25.
I send and receive mail to Gmail, it's fine, the mail goes to Gmail's inbox and doesn't spam.
But when I send to Yahoomail and Hotmail even Mail-tester gives error port 25:
<>: connect to[]:25: Connection timed out
<>: connect to[]:25: Connection timed out
<>: connect to[]:25: Connection timed out
I asked Support from CWP, they were also very enthusiastic but were unsuccessful.
They have a solution for themselves that should change the mail server name:

"I noticed that the server hostname you are using seems not correct, we do not recommend using the system words like mail. in server hostname. We recommend changing the server hostname to something else like server or server1 or srv or srv1."

"We already tried all other solutions, there is the only way to change the server hostname and the emails will start working fine."
I haven't changed it yet because I'm afraid it will damage the mail server because I'm sending it very well to Gmail.
Very headache.

Has anyone done this successfully with AWS SES?