Mail::Xoauth
Make the Mail work with Gmail using
OAuth. This
project is build on top of gmail_xaouth.
Mail::Xoauth
simply makes provides a nice connect to mail's rich
delivery and retrevial interface.
Installation
Add this line to your application's Gemfile:
gem 'mail-xoauth'
And then execute:
$ bundle
Or install it yourself as:
$ gem install mail-xoauth
Usage
This gem does not retreive oauth access or refresh tokesn for you!
You must retrieve them yourself. Mail::Xoauth
requires an access
token. It's up to you to ensure a valid access token using a refresh
token. If you do not know how to do that, then look at the tests.
There is an example class to handle this. Given a valid oauth access
token and email address you're ready to connect.
Getting Email
gmail = Mail::XOauthIMAP.new address: 'example@gmail.com', access_token: 'foo'
# Query using Mail's standard interface
gmail.all
Sending Mail
email = Mail.new do
from 'example@gmail.com'
to 'example@example.com'
subject 'XOauth Test'
end
gmail = Mail::XOauthSMTP.new address: 'example@example.com', access_token: 'foo'
gmail.deliver! email
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