To do web site testing, how can I disable or block the Centos server to not send out emails.

Now, if I run in command line

mail xxx@gmail.com

I can send out emails. This is not good for website testing. I don't want to cause trouble to users of the site.

Is it something to do with iptables? Can anyone enlighten the way?

I installed Centos with minimum package. I think it's the qmail that does the delivery job

locate qmail

I guess something like that would do:

iptables -A OUTPUT -p tcp --dport 25 -j REJECT

dport is the destination port 25, for SMTP. Packets will simply be dropped. To apply the rules you need to run:

/sbin/service iptables save

Here's the CentOS iptables documentation.

Can't test it, but should work.

  • -j REJECT would be much better in such cases. With DROP, the MTA would keep retrying forever to deliver the message. – grawity Jun 1 '11 at 18:43
  • ...wait, I think I got confused myself here. I suppose receiving a reject would cause MTA to retry, too, so my previous comment isn't exactly correct. Still, I prefer REJECT over DROP myself, because the former closes the connection immediately, while the latter causes the MTA to wait for timeout (which may be quite long). – grawity Jun 1 '11 at 18:56
  • @grawity Yes, it did make sense what you said. I'd just change the retry options for the MTA, but once you're there, there might be an option to disable sending as well without using iptables.. – slhck Jun 1 '11 at 19:01
  • Would this also block incoming? – Blue Eyed Behemoth Feb 8 '18 at 19:19
  • 1
    @BlueEyedBehemoth No, as that's using a different port. – slhck Feb 8 '18 at 20:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.