<snip src="http://matt.blogs.it/entries/00002655.html">
Well yesterday I mocked up the simplest, dumbest, Ruby SMTP server you can imagine. It's called Mailtrap and that's exactly what it does. It speaks just enough SMTP to allow ActionMailer to make a connection and send it a message. Mailtrap writes the message into a file for you (and you can tail -f the file if you're interested in seeing it).
</snip>
*Installation*
sudo gem install mailtrap
james@lucia:~/ruby$ sudo gem install -y mailtrap
[sudo] password for james:
INFO: `gem install -y` is now default and will be removed
INFO: use --ignore-dependencies to install only the gems you list
Successfully installed daemons-1.0.10
Successfully installed trollop-1.15
Successfully installed rubyforge-2.0.3
Successfully installed hoe-2.3.3
Successfully installed mailtrap-0.2.1
5 gems installed
Installing ri documentation for daemons-1.0.10...
Installing ri documentation for trollop-1.15...
Installing ri documentation for rubyforge-2.0.3...
Installing ri documentation for hoe-2.3.3...
Installing ri documentation for mailtrap-0.2.1...
Updating class cache with 662 classes...
Installing RDoc documentation for daemons-1.0.10...
Installing RDoc documentation for trollop-1.15...
Installing RDoc documentation for rubyforge-2.0.3...
Installing RDoc documentation for hoe-2.3.3...
Installing RDoc documentation for mailtrap-0.2.1...
james@lucia:~/ruby$ irb1.9.1
irb(main):001:0> require 'mailtrap'
=> true
irb(main):002:0>
irb(main):003:0* Mailtrap.new 'localhost', 2525, true, "mailtrap.txt"
Helo: HELO localhost
From: MAIL from: <james@rorbuilder.info>
To: RCPT to: <info@rorbuilder.info>
+ From: james@rorbuilder.info
+ To: info@rorbuilder.info
+ Subject: Test message
And we're done with that bozo!
=> #<Mailtrap:0xa538124 @host="localhost", @port=2525, @once=true, @msgfile="mailtrap.txt">
irb(main):004:0>
james@lucia:~/heroku/store$ telnet localhost 2525
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 localhost MailTrap ready ESTMP
HELO localhost
MAIL from: <james@rorbuilder.info>
250 OK
RCPT to: <info@rorbuilder.info>
250 OK
DATA
354 Start your message
From: james@rorbuilder.info
To: info@rorbuilder.info
Subject: Test message
.
250 OK
QUIT
221 Seeya
Connection closed by foreign host.
Resources:
- rubymatt's mailtrap-0.2.1 Documentation [rubyforge.org]
- gserver: Ruby Standard Library Documentation [ruby-doc.org]
- Mailtrap [blogs.it]