Forum Discussion
Thomas_Schaefer
Nimbostratus
Apr 23, 2009Make a Dummy SMTP server in an iRule?
I have a need to create a dummy SMTP server in an iRule. My thought was to use the SMTP proxy iRule and instead of forward the messages on to the SMTP server to discard them.
I am trying to do this because I have a DR system that I would like the apps that send mail to think they did send the mail, but I just want to eat the messages. I need to respond with the correct things to them (like the proxy), but I do not want to send the traffic on. This is essentially a mock object for SMTP.
I thought I could just add a discard statement before the return statement in the
SMTP Proxy like this:
if { $cdata starts_with "HELO" } {
set chelo [TCP::payload]
log local0. "get helo <$cdata>"
TCP::respond "250 OK\r\n"
TCP::payload replace 0 [string length $chelo] ""
discard
return
I am concerned that discard will terminate the connection.
My question is should this work?
Thanks,
Tom Schaefer
@thomasmschaefer
- Thomas_Schaefer
Nimbostratus
Thanks! That worked with just some minor modifications. My client tries to send EHLO and expects that response. All I did was reject the EHLO with a 500 error and it sends back the HELO command. I also had to respond to QUIT with a 221. Here is the updated code:switch -glob [string toupper [TCP::payload]] { DATA* { set respond "354 Start mail input; end with .\r\n" set data 1 } EHLO* { set respond "500 Syntax error, command unrecognized\r\n" } QUIT* { set respond "221 Bye\r\n" } default { set respond "250 Ok\r\n" } }
- Nat_Thirasuttakorn
Employee
TCP::collect in CLIENT_DATA is to make sure we keep collecting data so that CLIENT_DATA is called again and never send the data (never TCP::release)
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects