Advertisement
Guest User

Untitled

a guest
Jul 31st, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #!/usr/bin/ruby -w
  2. require 'net/imap'
  3. require 'net/smtp'
  4. imap_server = 'myserver'
  5. app_dir="myrailsapppath"
  6. cmd = "script/runner 'IncomingCommandHandler.receive(STDIN.read)'"
  7. username = 'myuser'
  8. password = 'mypass'
  9. conn = imap = Net::IMAP.new(imap_server, 143)
  10. Dir.chdir(app_dir)
  11. conn.login(username, password)
  12. conn.select('INBOX')
  13. conn.search(['UNSEEN']).each do |message_id|
  14. envelope = imap.fetch(message_id, "ENVELOPE")[0].attr["ENVELOPE"]
  15. puts `echo #{envelope} | #{cmd}`
  16. end
  17. conn.disconnect
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement