7

I have a Linux web app.

Do I need to open port 25 to only send emails using the PHP mail function? If I have to open port 25, how can I disable receiving emails?

Edit: I am asking because I understand that sendmail is the message transfer agent on my server.

4 Answers 4

5

php mail() function relies on sendmail like binary to send mail.

any MTA ( service listening on port 25 ) has program like sendmail that will serve the purpose.

if you don't want to have port 25 open, you can firewall it for all connections comming from the world; for example

iptables -I INPUT -p tcp -i eth0 --dport 25 -j REJECT

9

No.

As long as your firewall rules permit outbound traffic you do not need to open port 25 to send an email.

Port 25 only needs to be open if you wish your machine to receive email.

2

It depends on how the firewall is configured on the server / gateway / wherever.

Most of the time, firewalls block incoming traffic, such as traffic on port 25 coming to your server. Having said that, I usually configure firewalls to only allow outbound traffic on port 25 from known mail servers.

Either way, it's really dependent on your firewall configuration, but to answer your question with as much detail as you asked it... opening 25 outbound does not equal having 25 open inbound. If you enable outbound traffic on port 25, you'll be able to send mail. If you leave it closed inbound, then you'll not be able to receive mail.

This of course depends where the firewall lives in your network topology...

2
  • 1
    Huh? No. Sending mail to a remote SMTP server uses a random source port. You do not need to "enable outbound traffic on port 25". You would "enable outbound traffic to port 25". If that's what you meant, apologies, but it's not clear. Also, outbound firewall rules are an advanced topic that I suggest inexperienced admins avoid.
    – hobodave
    Feb 17, 2011 at 1:09
  • Yeah, apologies for not being clearer on that. I more meant that he'd need to enable outbound connections on 25 as a destination port.
    – dotalchemy
    Feb 17, 2011 at 1:22
2

If you only want to send emails and not receive Emails you could open port 25 out but not in. Or you could use a non-standard port relay such as NO-IP relay( no relation to company). Though I am not sure why you want this.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .