Skip to content

Instantly share code, notes, and snippets.

@kennethkalmer
Created July 23, 2010 12:15
Show Gist options
  • Save kennethkalmer/487369 to your computer and use it in GitHub Desktop.
Save kennethkalmer/487369 to your computer and use it in GitHub Desktop.
Very simple SMTP sinkhole that just prints the messages to stdout
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