Score:0

ufw configuration for smtp connections

vn flag

I have a PHP application running on a Debian server with UFW as firewall. The application needs to connect to a SMTP to send mails.

It works when I disable UFW. When it's enabled, the PHP application just keeps waiting. These are my rules:

UFW rules

The SMTP port is 465. I think it's because it can't send packages back from the smtp host. But which ports to I need to open for that? When I connect to the SMTP from the server, the port is just random.

cn flag
Bob
SMTP is TCP port 25 (other ports can be used but will only be used when explicitly configured in the client connecting to that server, in all other cases e-mail traffic from one smtp server to another will use port 25)
Score:0
pe flag

As Bob mentioned the port for smtp is 25.

Port 25 is the original standard email SMTP port and the oldest, since it first debuted in 1982. Today, the Internet Assigned Numbers Authority (IANA), the group responsible for maintaining the internet addressing scheme, still recognizes port 25 as the standard, default SMTP port.

On the modern web, there’s not a single SMTP port. Instead, there are four common SMTP ports:

25

587

465

2525

If you’re configuring your WordPress site or email client to send emails via SMTP (submission), you’ll almost always want to use port 587. Again, this is the default SMTP port for submission and it supports secure transmission via TLS.

If port 587 is blocked for some reason, port 2525 is a common alternative. Again, this is not an officially recognized SMTP port, but it is commonly used and supported by most providers.

While many providers still do support port 465 for SMTP, it’s no longer an accepted standard and you should always try to use ports 587 and 2525 before using port 465.

Finally, while port 25 is commonly used for SMTP relay, you should not use it when setting up an email client or WordPress website because most ISPs and cloud hosting providers block port 25.

I left you this reference How to Choose the Right SMTP Port (Port 25, 587, 465, or 2525)

vn flag
The email provider use port 465 with SSL authentication.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.