Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # biff.rb
- #
- require 'net/pop'
- require 'nkf'
- require 'rubygems'
- require 'ruby-growl'
- require 'pit'
- config = Pit.get("mail", :require => {
- "server" => "pop3 server",
- "port" => "pop3 port",
- "user" => "user account",
- "pass" => "password"
- })
- serv = config["server"]
- port = config["port"].to_i
- user = config["user"]
- pass = config["pass"]
- mails=[]
- Net::POP3.start(serv, port, user, pass) {|pop|
- mails = pop.mails.collect {|m| m.header}
- }
- exit if mails.empty?
- growl = Growl.new("localhost", "Biff", ["Notify"])
- growl.notify("Notify", "Mail recieved", "#{mails.size} of mail(s) recived.")
- sleep 5
- mails.each {|m|
- subject = NKF.nkf('-Jw', m.match(/^Subject:\s+(.*)/)[1])
- from = NKF.nkf('-Jw', m.match(/^From:\s+(.*)/)[1])
- growl.notify("Notify", "#{from}", "#{subject}")
- sleep 2
- }
Add Comment
Please, Sign In to add comment