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

0 Members and 1 Guest are viewing this topic.

Offline
*
Greetings!

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: https://wiki.centos-webpanel.com/how-to-setup-remote-smtp-server-as-relay
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:
http://forum.centos-webpanel.com/index.php?topic=676.0


The only topic I see that work is this one: http://forum.centos-webpanel.com/index.php?topic=9963.msg34954#msg34954
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:
http://forum.centos-webpanel.com/index.php?topic=6186.0
http://forum.centos-webpanel.com/index.php?topic=8754.0
https://forum.centos-webpanel.com/e-mail/how-to-change-port-mail-server-my-isp-blocked-port-2526/
https://forum.centos-webpanel.com/index.php?topic=8956.msg31330#msg31330
https://forum.centos-webpanel.com/index.php?topic=3244.msg11820#msg11820
https://forum.centos-webpanel.com/index.php?topic=3716.msg12935#msg12935
https://forum.centos-webpanel.com/index.php?topic=5634.msg19572#msg19572
https://forum.centos-webpanel.com/index.php?topic=5365.msg18664#msg18664
https://forum.centos-webpanel.com/index.php?topic=6317.msg21870#msg21870


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.server.com
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/main.cf , Add the following lines
Code: [Select]
#Relay
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:
example.com
helloworld.com
niceday.com

The SMTP server provided to me was smtp.server.com with port 587

I will add the following:
Code: [Select]
@example.com            smtp.server.com:587
@helloworld.com         smtp.server.com:587
@niceday.com            smtp.server.com:587

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


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]
smtp.server.com:587   YourUsername:YourPassword


Note that smtp.server.com:587 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


DONE!
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/main.cf.

Code: [Select]
debug_peer_list=smtp-relay.rubel.com
debug_peer_level=3


The Postfix configuration must be reloaded after updating the main.cf 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*

or

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 »

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

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


Thank you very much in advance

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

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


Thank you very much in advance

Hello,

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.