Skip to content

hatappi/send_gmail

Repository files navigation

SendGmail

send_gmail handles gmail.
now it features only the acquisition of e-mail. this gem is using gmail api.
https://developers.google.com/gmail/api/

Feature

  • create draft
  • on/off label
  • other...

Installation

Add this line to your application's Gemfile:

gem 'send_gmail'

And then execute:

$ bundle

Or install it yourself as:

$ gem install send_gmail

To begin with

$ client = SendGmail::Client.new
$ client.authorize(credentials_path, client_id, client_secret, scope)

First Time

  1. browser auto open and login user
  2. auto write oauth information to credentials_path

From second time

  1. if credentials_path is exist, browser no need to open

Incoming mail

$ mail_id_list = client.mail_id_list(searching_option)
  => {
   :mail_id_list=>["ffffff", "ccccc", ...],
   :next_page_token=>"123456789"
   }

$ mail_id_list[:mail_id_list].map { |mail_id| client.mail_detail(mail_id) }
  => [#<SendGmail::Objects::Mail... , ...]
$ mail_list = client.mail_list(searching_option)
  => {
   :mail_id_list => [#<SendGmail::Objects::Mail... , ...],
   :next_page_token => "123456789"
   }

Outgoing mail

$ client.send_mail(to, subject, msg, from = nil, bcc = nil, cc = nil, user_id = 'me')
  => 200

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/hatappi/send_gmail.

License

The gem is available as open source under the terms of the MIT License.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published