Skip to content

Instantly share code, notes, and snippets.

@r38y
Created June 29, 2009 02:31
Show Gist options
  • Save r38y/137436 to your computer and use it in GitHub Desktop.
Save r38y/137436 to your computer and use it in GitHub Desktop.
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