Adding Gmail IMAP directly into a Rails application is quite easy. As Pramod explains in this post.
We often need to read user email messages from Gmail, In this post I will be taking you through how to access user inbox messages from Gmail using gmail_xoauth gem and Ruby Net::IMAP Net library in your Rails application.
I have the sample example file on gist , I would suggest refer this example side by side with this post.
gmail_xoauth allows you to authenticate Gmail IMAP and STMP via OAuth, using the standard Ruby Net libraries. Gmail Platform provides XOAUTH2 mechanism a OAuth 2.0 protocol used for IMAP AUTHENTICATE and SMTP AUTH commands.
Ruby implements Internet Message Access Protocol (IMAP) client functionality in Net::IMAP Net libraries.
Before we start here are some prerequisite,
1) You need to Authorize user via Google using omniauth-google-oauth2 with omniauth configuration specified in sample omniauth_config.rb
2) While Authorize you must define following scopes.
3) If you are accessing user email in offline mode then you need…
View original post 260 more words