Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- # ghetto gmail sms notification while I wait for GPush and when MsgPush fail
- # Usage: ./gmail_sms_push.rb &
- require 'net/imap'
- require 'net/smtp'
- domain = 'yourdomain.com'
- from = "user@#{domain}"
- username = 'username'
- password = 'password'
- sms_email = '1234567890@txt.att.net'
- new_mail_msg = "You've got mail!"
- sleep_interval = 30
- (imap = Net::IMAP.new('imap.gmail.com', 993, true)).login(username, password)
- begin
- imap.select('INBOX')
- new_uid = imap.search(['ALL']).last
- @last_uid ||= new_uid
- if new_uid > @last_uid
- (smtp = Net::SMTP.new('smtp.gmail.com', 587)).enable_starttls_auto
- smtp.start(domain, username, password, :plain) { |smtp| smtp.send_message(new_mail_msg, from, sms_email) }
- @last_uid = new_uid
- end
- sleep sleep_interval
- end while true
Add Comment
Please, Sign In to add comment