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
/usr/share/logwatch/scripts/services/qmail
/usr/share/logwatch/scripts/services/qmail-pop3d
/usr/share/logwatch/scripts/services/qmail-pop3ds
/usr/share/logwatch/scripts/services/qmail-send
/usr/share/logwatch/scripts/services/qmail-smtpd
share|improve this question
up vote 13 down vote accepted

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.

share|improve this answer
    
-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
    
@grawity Thanks, I changed it. – slhck Jun 1 '11 at 18:46
    
...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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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