Gmailish
Grabs unread emails from Gmail, marks them as read, applies a Transfered
label and archives them.
Installation
Add this line to your application's Gemfile:
gem 'gmailish', '~> 0.0.1'
And then execute:
$ bundle
Or install it yourself as:
$ gem install gmailish
Usage
See Mail documentation here.
account = Gmailish::Account.new(username, password)
#=> #<Gmailish::Account:0x007f89dcaa7950>
account.process
#=> #<Gmailish::Account:0x007ff175d69ed0>
= account.
#=> [#<Mail::Message:70337520506800>, #<Mail::Message:70337520506801>]
= .first
.envelope.from #=> '[email protected]'
.from.addresses #=> ['[email protected]', '[email protected]']
.sender.address #=> '[email protected]'
.to #=> '[email protected]'
.cc #=> '[email protected]'
.subject #=> "This is the subject"
.date.to_s #=> '15 Aug 2013 09:55:06 -1100'
. #=> '<[email protected]>'
.body.decoded #=> 'This is the body of the email..
Example
GmailService.retrieve
#=> [#<Mail::Message:70337520506800>, #<Mail::Message:70337520506801>]
class GmailService
def self.retrieve
new.
end
def
@messages ||= mailer.
end
private
def mailer
Gmailish::Account.new(username, password).tap do |account|
account.process
end
end
def username
ENV['GMAIL_EMAIL']
end
def password
ENV['GMAIL_PASSWORD']
end
end
Requirements
- ruby > 1.9.x
- net/imap
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request