LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   How can I check if port 25 open for outgoing or to send email only? (https://www.linuxquestions.org/questions/linux-networking-3/how-can-i-check-if-port-25-open-for-outgoing-or-to-send-email-only-4175736081/)

cola 04-16-2024 05:38 AM

How can I check if port 25 open for outgoing or to send email only?
 
How can I check if port 25 open for outgoing or to send email only?

I mean, I want to send email through 25 port. I do not want to receive email through 25 port.

If I do telnet smtp.gmail.com 25, it said connected and it prompts to enter input. Does that mean the port 25 open for sending email?

But from online port checker tool, for my public ip address, I see, port 25 is closed.

TenTenths 04-16-2024 05:49 AM

Quote:

Originally Posted by cola (Post 6496284)
If I do telnet smtp.gmail.com 25, it said connected and it prompts to enter input. Does that mean the port 25 open for sending email?

Yes

Quote:

Originally Posted by cola (Post 6496284)
But from online port checker tool, for my public ip address, I see, port 25 is closed.

Unless you've specifically opened a port on your router and are forwarding it to a listener then it will appear closed.

cola 04-16-2024 06:27 AM

So I can say that the port 25 is open for outgoing but closed for incoming, right?

pan64 04-16-2024 06:48 AM

I guess it is not precise enough.
port 25 is used to receive a connection (from server side), or with other words to connect to a mail server (client side).
Client can communicate with the given mail server ( smtp.gmail.com ) on the given port of that mail server and can use it to send mails. The port on the client side is not important, but most probably it is not 25.
You can only send mails using this smtp port with the client.

https://www.duocircle.com/content/sm...ce/smtp-server
https://serverfault.com/questions/74...g-emails-works

boughtonp 04-16-2024 08:44 AM


 
Running "ss -pltn" (as root/sudo) will tell you which processes are listening on which TCP port numbers.

If something is listening on port 25, that port is open - unless there are firewall/router rules changing that.

If nothing is listening on port 25 (and there's nothing forwarding port 25 to another port) then that port is closed.


scasey 04-16-2024 09:40 AM

My understanding is that port 25 (smtp) is the default port for receiving email messages. In order for that to work, a Mail Transport Agent (MTA) (sendmail, qmail, etc.) must be listening on the port and accepting connections.

The telnet connection prompting for input indicates that the port is open for receiving email.

Sending email does not use port 25 on the sending server.. The MTA must be able to connect to port 25 on other, foreign servers, but it doesn’t use the local port 25 to do that…mainly because that port is not available for that. It’s busy listening for and receiving email.

These days, of course, the sending server must comply with several conventions and rules in order for receiving servers to accept the email it sends, but that’s a whole other subject.

Is this a home computer? A server on the internet? What?

Skaperen 04-20-2024 06:22 PM

understand that while a TCP connection exists there are two ports involved, one on each end. when the connection is being made, one end is sending a request to establish a connection to the other end. the end that is sending is known as the source. the other end that is being targeted is known as the destination which needs to be listening for incoming connection requests for the port number on that end. the request that arrives will have a source address and source port. once the connection is established, four numbers together (known as a tuple) uniquely identify the connection in a particular direction. flip the source and destination pairs to identify the same connection in the reverse direction. no other connection will have all of these numbers at the same time (or for a couple minute afterwards). network activity (routing, filtering, accepting, etc.) will generally be based on one or two particular numbers (possibly from lookup results of particular configured name). it is important to say which number when stating number. in most cases this is obvious as in "connecting to port 25" (assumed to mean the destination port is 25 and the source port could be some random number like 18336). each end has an address as well, where you are "connected to" (such as the target mail server) and where you are "connected from" (such as the address your laptop got this hour). be sure to avoid confusion or a mix-up of possibilities by explaining what each number is to us (like "dest port 25") and being as complete as possible.

> My understanding is that port 25 (smtp) is the default port for receiving email messages.

to be more precise it is for exchanging email (when considering both sides generally need to run a mail server). for a single piece of email we look at the destination address, but both sides will usually be listening for port 25 when both sides are email servers.

> Sending email does not use port 25 on the sending server..

that can be confusing. both sides do have port 25 but a connect to send email uses port 25 for its destination and some random port for its source (such as 18336). the "sending server" does use port 25 but it uses is as a destination port so that it goes to the proper socket on the other server it connected to.

> Is this a home computer? A server on the internet? What?

indeed, these are questions we need answered by the original poster (OP).

i'm considering blocking port 25 from coming in because it seems all the spam comes in that way. will that affect my "send only" email?


All times are GMT -5. The time now is 04:35 AM.