Getting your Trinity Audio player ready...
|
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:
# yum -y install cyrus-sasl-plain mailx
Step 2
In /etc/postfix/main.cf , Add the following lines
#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:
@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
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:
# postmap sasl_passwd sender_relay
# postfix reload
Step 6
Now you can flush the email queue (attempt to deliver the previous emails).
# 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.
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.
debug_peer_list=smtp-relay.rubel.com
debug_peer_level=3
The Postfix configuration must be reloaded after updating the main.cf file.
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 )
# chown root:postfix /etc/postfix/sasl_passwd*
# chmod 640 /etc/postfix/sasl_passwd*
or
# chmod 600 sasl_passwd
# chown root:root sasl_passwd