Created
June 29, 2009 02:31
-
-
Save r38y/137436 to your computer and use it in GitHub Desktop.
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 'tmail' | |
require 'rest_client' | |
DESTINATION = ARGV.first || 'http://localhost:4567/posts' | |
class Message | |
def self.receive(raw) | |
message = parse(raw) | |
params = {} | |
[:to, :from, :subject].each{|f| params[f] = message.send(f)} | |
resource = RestClient::Resource.new DESTINATION | |
resource.post params | |
end | |
def self.parse(raw) | |
TMail::Mail.parse(raw) | |
end | |
end | |
Message.receive(STDIN.read) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment