Skip to content

Instantly share code, notes, and snippets.

@fabriziogiordano
Created April 25, 2012 20:45
Show Gist options
  • Save fabriziogiordano/2493225 to your computer and use it in GitHub Desktop.
Save fabriziogiordano/2493225 to your computer and use it in GitHub Desktop.
require 'mail'
require 'net/http'
Dir.glob('./new/*.eml').each do |entry|
#File.rename(entry, entry+".work")
mail = Mail.read(entry)
body = ''
if mail.parts.length
mail.parts.each do |p|
if p.content_type.include? 'text/plain'
body = p.body
end
end
else
body = mail.body
end
url = URI.parse('http://www.ffanculo.com/incomingemail')
post_args = {
'message_id' => mail.message_id,
'from' => mail.from,
'body' => body
}
resp, data = Net::HTTP.post_form(url, post_args)
puts resp.body
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment