Skip to content

Instantly share code, notes, and snippets.

@bengotow
Created August 22, 2014 01:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bengotow/e4635db54eb6c241fc89 to your computer and use it in GitHub Desktop.
Save bengotow/e4635db54eb6c241fc89 to your computer and use it in GitHub Desktop.
Ping back and forth between two email accounts over and over forever using Inbox
#!/usr/bin/env ruby
require 'inbox'
@inbox_careless = Inbox::API.new('xdfim6g4mbduytzjhn8ud490', '80q785tt4l6qn5g07c5ylwi6a', '<<token 1>>')
@inbox_emoink = Inbox::API.new('xdfim6g4mbduytzjhn8ud490', '80q785tt4l6qn5g07c5ylwi6a', '<<token 2>>')
emoink = @inbox_emoink.namespaces.first
careless = @inbox_careless.namespaces.first
while true do
puts "Checking..."
# Print out threads with the subject 'Daily Update'
careless.threads.where(:subject => 'Ping', :tag => 'unread').each do |thread|
body = thread.messages.first.body
if (body != '')
puts "Roundtrip time: " + (Time.now.to_i - body.to_i).to_s;
else
puts "Got Start Ping"
end
thread.mark_as_read!
draft = emoink.drafts.build(
:to => [{:name => 'Careless', :email => 'careless@foundry376.com'}],
:subject => "Ping",
:body => Time.now.to_i.to_s
)
draft.save!
draft.send!
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment