Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Background: I am integrating two separate web application that are developed in ASP .NET and JSP/Struts. As such, they are hosted on two different server technologies, namely Win2K3 and Redhat Enterprise Server 5.5.

Problem: There is a copy of production data in my test environment with real e-mail addresses. I need to test the e-mail functionality of these applications, but I do not want them to send out actual e-mails. Is there a way to catch and redirect all outgoing e-mails?

Ideally, I would like to send all outgoing e-mails to another e-mail (i.e., test@test.com) so my testers can look at them.

Thanks for the help in advance!

share|improve this question
    
I would break this up into seperate questions as the answers will be different on the different architectures –  Jim B Apr 21 '10 at 21:10
    
Good advice Jim. I'll create a second one for WIN2K3. –  John Apr 22 '10 at 18:13
    
In case anyone is wondering, I've created a separate post specifically for Win2K3 here serverfault.com/questions/135025/… –  John Apr 22 '10 at 20:14

1 Answer 1

up vote 1 down vote accepted

First, you should scrub real data out of your development environment. Also be aware that there are a lot of variables and options here.

On the Linux development server, I would first prevent the mail from sending out by either filtering the traffic or stopping the mail daemon. To stop the traffic, this would work in most modern environments:

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

My development network cannot connect externally to this and most other ports already, as it is a default drop policy and I do not allow exceptions. I typically dedicate a relay smtp to each subnet, where I can enforce additional relay policies there. Development servers aren't allowed to relay through this host either.

Later, you may have to clear the mail out of the mail queue before restarting the daemon or removing the rule depending on your approach.

On Windows, typically you do not have a local mail server running. Go to the source and prevent it from working or point to the Linux server that's already dropping the e-Mail.

If you are sharing the same smtp relay host between the servers, you could stop mail relay from those servers. If they are sharing the same gateway, you could drop the traffic there.

If you want to test application functionality, you could create a test e-Mail account local to the server and have the e-Mail delivered there or view the outgoing e-Mail logs. That's what I enforce in our development environment. In my case, development can only e-Mail local user accounts on the server specific, period. No relaying or delivery to local mail servers. Anything more introduces the potential for error and it's very likely to occur.

If you still insist on rerouting all outgoing mail, the solution is going to be dependent upon your MTA.

share|improve this answer
    
It's notable I've known Java applications to bypass local mail queuing and use TCP sockets to connect to a remote MTA. –  Warner Apr 21 '10 at 20:18
    
Thanks for the information Warner. Is there a way to simply catch the traffic and redirect though? One of the services I am working with I only have the binaries for, so I cannot simply go in and modify the code. We're working on getting access to the source code, but we need to figure out an alternative in case we don't get access. –  John Apr 22 '10 at 14:16
    
Potentially a static route or some sort of NAT. The solution there is probably best on the network layer. –  Warner Apr 22 '10 at 15:49

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.