Created
July 23, 2010 12:15
-
-
Save kennethkalmer/487369 to your computer and use it in GitHub Desktop.
Very simple SMTP sinkhole that just prints the messages to stdout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'eventmachine' | |
class SmtpSink < EM::Protocols::SmtpServer | |
def receive_data_chunk( data ) | |
buffer.concat data | |
end | |
def receive_message | |
puts | |
puts "<message>" | |
puts buffer.join("\n") | |
puts "</message>" | |
puts | |
clear_buffer! | |
true | |
end | |
def buffer | |
@buffer ||= [] | |
end | |
def clear_buffer! | |
@buffer = [] | |
end | |
end | |
EM.run { | |
EM.start_server( '0.0.0.0', 25, SmtpSink ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment