GithubHelp home page GithubHelp logo

gmail's People

Contributors

abhishiv avatar achiurizo avatar alexgenco avatar awakia avatar bb avatar beam avatar bootstraponline avatar dcu avatar drewda avatar fgalassi avatar iamwilhelm avatar jgrevich avatar joelparkerhenderson avatar johnnyshields avatar jonpierce avatar kieranp avatar mikker avatar namxam avatar nu7hatch avatar radar avatar rjain11 avatar rtlong avatar ryanlchan avatar slash4 avatar webcracy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gmail's Issues

What is the best way to handle emails periodically ? loops / eventmachine

Hi,

I was wondering that if I want the client to keep checking periodically new e-mails , what is the best way to achieve that ? simply to use a loop to do so https://gist.github.com/15a72402911368920903 ? or you recommend using eventmachine to do such a task .

One more question please, anyone got the chance to check out how many client can be run in parallel and if there limitations for that ?

I assume that the code could be modified to work with different type of clients as well if i'm not mistaken .

Thanks in advance

how to unpack ?

Can you give me any tips about unpacking. Some email bodies say use "munpack". Although, i can save the body and run munpack, is there anyway to determine at time of mail.body that unpack is required.

Is there some routine in gmail gem or mail gem that does the unpacking?
Thanks a lot.

message.delete_label!(xxx) doesn't seem to work

Hi all,

I'm finding that I can add labels easily enough using message.label!("test")

but then message.delete_label!("test") doesn't seem to remove the label.

I note that labels are applied to converations in gmail rather than individual messages - I wonder if that is the problem, though it doesn't work even when there is only one message in the conversation.

I've checked the implementation in the source and it seems to just move the message back into all mail folder so not entirely sure how to fix this.

Is anyone else having this problem?

Steve

How to search for emails and permanently delete them?

Hi,
I was looking for ways to permanently delete emails after applying filters. Does the gem support it now?

I know delete! moves them to trash, but once an email is received with the same subject line the emails from trash are moved to their original folder again.

Thanks!

Never logs in, never errors out

I was trying a more complex oauth example, until I realized that wasn't my problem...

Gmail.connect!('[email protected]', 'DUHPASSWORD') do |gmail|

  puts gmail.logged_in?
  puts "test succeeded!"
end

puts "test succeeded?"

Always prints the second line, and never the first line, so it's not executing the block...

So I tried

gmail=Gmail.connect!('[email protected]', 'DUHPASSWORD')

  puts gmail.logged_in?

and it always returns false. I checked my password. I checked network. I'm using the latest every gem and ruby, bundle update and rvm get head; rvm upgrade 1.9.3

I have tried both .connect and .connect! so I expected I would see an error raised when the (whatever) failed, but no error is raised and the block never gets executed. Any idea?

find(:attachment) > returns "can't dup NilClass"

If I do :

@gmail.mailbox(@boxname).emails(:attachment)

I get a TypeError : can't dup NilClass

But if I do :

@gmail.mailbox(@boxname).emails(:unread)

Everything works fine... Any idea ?

Thanks.

installation failure

I'm getting this message when I try to install using rake install

no such file to load -- ore/tasks
Run gem install ore-tasks to install 'ore/tasks'.
no such file to load -- metric_fu
Run gem install metric_fu to install Metric-Fu
WARNING: 'require 'rake/rdoctask'' is deprecated. Please use 'require 'rdoc/task' (in RDoc 2.4.2+)' instead.
at /var/lib/gems/1.8/gems/rake-0.9.2.2/lib/rake/rdoctask.rb
rake aborted!
Don't know how to build task 'install'

I have installed 'ore' but still the same error, and coudnt install metric_fu because of some dependency error

does this work with 1.9.2

ruby-1.9.2-head > Gmail.connect("[email protected]","xxx") do |gmail|
ruby-1.9.2-head > gmail.inbox.count
ruby-1.9.2-head ?> end
Net::IMAP::BadResponseError: Unknown command z5if11396491vco.62

and

ruby-1.9.2-head > gmail = Gmail.connect!("[email protected]","xxxxx")
NoMethodError: undefined method `data' for "Couldn't login to given GMail account: [email protected]

(I am on a macosx snow leopard, using rvm 1.9.2)

Move email back to Inbox

Anyone know how to move an email back to the Gmail inbox with this gem (or with Net:IMAP)? We successfully move emails out of the Inbox by copying them to another mailbox, then setting the 'delete' flag on the copy in the Inbox. We'd like the user to be able to revert tagging errors, but when we reverse the steps and tell Gmail via IMAP to copy the email from a user-created mailbox back into the Inbox, it does not work -- we get a success flag, but the email does not show up in the Inbox, even after it is deleted from the user-created mailbox so that it has no tags on it. Suggestions welcome!

label colors

Hi, first of all thanks for this great gem. Is there a way to set label colors? does the API even allow this?

Retrieving new messages since last connection

Is there anyway to recover only new mail since the last connection, using for example the last UID message read? I understand it should be easy but i don't know how to do it.

Thanks in advance

Couldn't login to given GMail account: [email protected]

Every once and a while ( local dev machine ) I run into this problem.
No idea what is causing it.

Couldn't login to given GMail account: [email protected]

My code running in a controller:

    begin
      logger.info("log in")
      gmail = Gmail.connect!('[email protected]','44444444444')
      @emails = gmail.inbox.find(:from => "*@domain.tld", :after => Date.parse("2011-07-10")).reverse
    rescue Exception => exc
      logger.error("could not get to the emails: #{exc.message}")
    ensure

    end

I would be more than happy to provide more debug information.

  • Ruby 1.8.7 p 352
  • Ruby On Rails 2.3.8
  • Using RVM
gem list gmail

*** LOCAL GEMS ***

gmail (0.4.0)
gmail_xoauth (0.3.0)

Improperly processing labels containing parentheses

Gmail gem will crash when attempting to download a message's labels using the X-GM-LABELS extension when the labels contain a parenthesis (e.g. "Label (crashes)").

Error is cause by using Net::IMAP::ResponseParser#flag_list to load label data; Net::IMAP's FLAG_REGEXP improperly escapes parentheses, which causes the parser to crash.

Solution would be to create a set of dedicated functions to process labels based on the #flag_list model, but using a more inclusive regexp.

Download all mails without attachment

Hello !
First of all, thank you for this great job.
I want to download all mails from gmail to process them but it's very slow. For example I've done :

        gmail = Gmail.connect("login","pass")
        mails = gmail.inbox.emails(:read)
        person = Hash.new(0)

        mails.each { |mail|
            // processing
        }

I thin it is very slow because I download mail with attachment ? Can I skip that ?
Thank you !

undefined method `save_attachments_to' for Gmail::Message

I'm not able to save attachments:

unless email.attachments.empty?
  folder = "/public/system/files/"
  begin
    email.save_attachments_to( folder )
  rescue Exception => exc
    logger.error( exc.message )
  ensure
end

error message
```undefined method`save_attachments_to' for #<Gmail::Message0x123 mailbox=INBOX uid=124222>


Also tried going through each attachment and save them using
```attachment.save_to_file( location )

but it also results in undefined method save_to_file

email.delete! moves to All Mail instead of Trash

Just tested email.delete! and it flags as deleted, which Gmail seems to use to archive (All Mail) instead of delete (Trash).

I tried to work around this by adding the '[Gmail]/Trash" label and then flagging as deleted, but that seems to put it in the trash and leave it in the inbox. Very strange.

email#message undefined method

I could run this:

gmail.inbox.emails(:unread).each {|e| p e.subject}

but not this:

gmail.inbox.emails(:unread).each {|e| p e.message}
NoMethodError: undefined method `message' for #Mail::Message:0x00000102cdc578

Good work, btw!

oAuth?

Is it possible to do this through oauth and not have to ask email and pass?
Thanks

Searching "All Mail" including inbox + archived

results = gmail.inbox.search(:subject => 'insert_keyword_here')

This returns only the items in Inbox (labeled with Inbox), not the ones in "All Mail" (also known as "archived email").

How can search in "All Mail", not just Inbox?

Track some emails

Hi,

I'm using gmail gem to send emails and I need track these emails. How can I do this?

I'm trying search the email with the message_id, but it bring all emails from my inbox and I want just the responses of a specific email.

Here is my actual code:

    #save email with the message_id
    ...
    mail = gmail.deliver(email)
    Email.create(:message_id => mail.message_id, :from => user.email,
      :to => annotation.to, :body => annotation.content, :title => annotation.title,
      :annotation => annotation, :user => user)
    #search the mails with message_id
    messages = gmail.inbox.mails(:message_id => email.message_id)

Regards,

Fabrício Ferrari de Campos

Request: include support for OAuth 2.0

Now that gmail_xoauth 0.4 supports Oauth2.0, is it possible to update this gem to allow for XOAuth2 authentication? Currently the gem is only configured for XOauth authentication.

If this is not going to occur in the foreseeable future, is anyone aware of a workaround that allows you to use the functionality of the gmail gem once successfully authenticated with IMAP Oauth 2.0 using the gmail_xoauth gem? Here is how I am currently authenticating with gmail_xoauth:

require 'gmail_xoauth'
imap = Net::IMAP.new('imap.gmail.com', 993, usessl = true, certs = nil, verify = false)
imap.authenticate('XOAUTH2', '[email protected]', my_oauth2_token)

possible race condition in emails()

I have one thread checking for count of unread emails in INBOX, another one is calling emails for all emails. I think the data is getting mixed.

The situation is that i use a thread to check unread counts for all labels (so that application is not held up). In the meantime, user fetches mails for Inbox. It appears that 2 concurrent calls for messages of one label, cause data inconsistency.

Perhaps this is an application issue, but i thought i would just point it out to you.

read_only mode

Firstly, thanks! I love this gem.

Secondly, here is one observation for my specific use case:

I have a script which is part of a custom CRM, it loops through all messages in a gmail account, and matches them up to a specific contact in our database.

When each message is downloaded from Gmail, it is automatically marked as read. This is very confusing for the owners of those mailboxes. There seems to be no method to get the read? or unread? status of a mail message which has just been accessed, otherwise I would simply mark it as unread! after I was finished. (Appears this is a limitation of the IMAP protocol).

The solution to this is deep inside the documentation for Net:IMAP, and it is to access the mailbox with "examine".

Here is some code I am using in an initializer which perfectly fits my use case, I am putting it here partly to help anyone who may stumble upon it from google, and partly to suggest the addition of a :read_only => true feature when connecting.

If there is enough demand for this, I'm happy to submit a patch.

Thanks!

module Gmail
  module Client
    class Base

      def switch_to_mailbox(mailbox)
        if mailbox
          mailbox = Net::IMAP.encode_utf7(mailbox)
          conn.examine(mailbox)
        end
        @current_mailbox = mailbox
      end

    end
  end
end

Can't install on heroku

It seems like the gmail gem has a dependency on sqlite3 which is preventing it from installing on heroku. Here is the trace from git push heroku master:

Installing sqlite3 (1.3.5) with native extensions Unfortunately, a fatal error has occurred. Please report this error to the Bundler issue tracker at https://github.com/carlhuda/bundler/issues so that we can fix it. Thanks!
/usr/local/lib/ruby/1.9.1/rubygems/installer.rb:483:in rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError) /usr/local/bin/ruby extconf.rb checking for sqlite3.h... no sqlite3.h is missing. Try 'port install sqlite3 +universal' or 'yum install sqlite-devel' and check your shared library search path (the location where your sqlite3 shared library is located). *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/usr/local/bin/ruby --with-sqlite3-dir --without-sqlite3-dir --with-sqlite3-include --without-sqlite3-include=${sqlite3-dir}/include --with-sqlite3-lib --without-sqlite3-lib=${sqlite3-dir}/lib --enable-local --disable-local Gem files will remain installed in /tmp/build_1fudaczth52a3/vendor/bundle/ruby/1.9.1/gems/sqlite3-1.3.5 for inspection. Results logged to /tmp/build_1fudaczth52a3/vendor/bundle/ruby/1.9.1/gems/sqlite3-1.3.5/ext/sqlite3/gem_make.out from /usr/local/lib/ruby/1.9.1/rubygems/installer.rb:486:inblock in build_extensions'
from /usr/local/lib/ruby/1.9.1/rubygems/installer.rb:446:in each' from /usr/local/lib/ruby/1.9.1/rubygems/installer.rb:446:inbuild_extensions'
from /usr/local/lib/ruby/1.9.1/rubygems/installer.rb:198:in install' from /tmp/build_1fudaczth52a3/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.0/lib/bundler/source.rb:90:inblock in install'
from /tmp/build_1fudaczth52a3/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.0/lib/bundler/rubygems_integration.rb:82:in preserve_paths' from /tmp/build_1fudaczth52a3/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.0/lib/bundler/source.rb:89:ininstall'
from /tmp/build_1fudaczth52a3/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.0/lib/bundler/installer.rb:73:in block in install_gem_from_spec' from /tmp/build_1fudaczth52a3/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.0/lib/bundler/rubygems_integration.rb:97:inwith_build_args'
from /tmp/build_1fudaczth52a3/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.0/lib/bundler/installer.rb:72:in install_gem_from_spec' from /tmp/build_1fudaczth52a3/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.0/lib/bundler/installer.rb:56:inblock in run'
from /tmp/build_1fudaczth52a3/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.0/lib/bundler/installer.rb:55:in run' from /tmp/build_1fudaczth52a3/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.0/lib/bundler/installer.rb:12:ininstall'
from /tmp/build_1fudaczth52a3/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.0/lib/bundler/cli.rb:220:in install' from /tmp/build_1fudaczth52a3/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.0/lib/bundler/vendor/thor/task.rb:22:inrun'
from /tmp/build_1fudaczth52a3/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.0/lib/bundler/vendor/thor/invocation.rb:118:in invoke_task' from /tmp/build_1fudaczth52a3/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.0/lib/bundler/vendor/thor.rb:263:indispatch'
from /tmp/build_1fudaczth52a3/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.0/lib/bundler/vendor/thor/base.rb:386:in start' from /tmp/build_1fudaczth52a3/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.0/bin/bundle:13:in<top (required)>'
from vendor/bundle/ruby/1.9.1/bin/bundle:19:in load' from vendor/bundle/ruby/1.9.1/bin/bundle:19:in

'
!
! Failed to install gems via Bundler.
!
! Detected sqlite3 gem which is not supported on Heroku.
! http://devcenter.heroku.com/articles/how-do-i-use-sqlite3-for-development
!
! Heroku push rejected, failed to compile Ruby/rails app

Modifying Constants during SEARCH

Hi,

thanks for this Gem. It was a bit hard to find because you didn't fork from dcparker/ruby-gmail so it didn't appear in the Github Network view.
It's good to see someone is carrying this project on, because the other seems to be orphaned and has a lot of bugs which made me try this one.

And I found one here, too:
In https://github.com/nu7hatch/gmail/blob/master/lib/gmail/mailbox.rb#L35 you're getting the entries from MAILBOX_ALIASES and use them directly which makes the a second, less constrained search fail. The line should read:

    search = MAILBOX_ALIASES[args.shift].dup

You can confirm this with these lines:

puts gmail.mailbox("[Gmail]/Spam").emails.count
puts gmail.mailbox("[Gmail]/Spam").emails(:to => "*a*").count
puts gmail.mailbox("[Gmail]/Spam").emails.count
puts Gmail::Mailbox::MAILBOX_ALIASES.inspect

Assuming not all emails in the Spam folder contain an "a" in the recipient, the second number should be smaller and the third number should be equal to the first one again, which is not the case currently. You can also check the MAILBOX_ALIASES after a search which constrains something.

Thanks for your work!
Cheers,
Benjamin

Best way to read the message.body

Hi, I recently used the gem and needed to interpret the real text of the message, I could do it with this code:

gmail.inbox.find(:unread).each do |mail|
bod = mail.message.body.to_s
end

Is this the best way to do get the message text or I made a workaround?

Tks and congrats for the gem =)

Is there a way to retreive sent emails ?

hello,

I need to do something, that I couldnt find until now. Is it possible to gather "sent" emails from Gmail ? I'm trying to reproduce the "is:sent" filter in standard Gmail search.

I've tried many things, like mailbox('sent'), gmail.sent.mails, mailbox('is:sent')... And if we search as usual : gmail.inbox.search("doe"), it doesnt fetch the sent mail.

Thanks a lot,

Alex

Gmail Message ID

Do you ever plan to add support for searching by message_id? This is not the email thread id, but the the Gmail frontend message id of the message (this is a 64-bit hexadecimal value, different from the RFC 822 Message-ID).

This is provided to Google Apps and contextual gadgets, and the message can be retrieved using this ID as follows:
http://code.google.com/apis/gmail/imap/#x-gm-msgid

I am not sure if the Ruby IMAP library supports it or what would be necessary to add it, but if this could be added that would be awesome.

'Net::IMAP::BadResponseError' >>> unknown command

This error occurs randomly while using the lib.

The exact problem is well described here : http://stackoverflow.com/questions/6385276/unknown-command-on-gmail-gem

I'm trying to get my emails using the Gmail gem (source) with the next call:

class MyClass
  def initialize account, credentials
    @gmail = Gmail.connect(account, credentials)
  end

  def get_attachments received_at, options
    mails = @gmail.inbox.find(
      :to => options[:to],
      :has=>:attachments,
      :before => options[:end_date],
      :after => received_at
     )
     #more code
   end
end

@gmail is a valid instance of Gmail class, and this call raises sometimes the next error:

Unknown command v2if4084974eef.9

The command (v2if4084974eef.9) changes in every call I make.

What am I doing wrong?

I'm using ruby-1.9.2-p180 and rails 3.1.0

Crazy memory usage when getting attachments

Hi there,

Loving the gem, but found some runaway memory usage when getting attachments to an email...the problem may actually be with the Mail gem itself, but figured I start here. I've got a gist below with the simplest code I could write that shows the problem.

I output memory usage after each step (getting unread emails from the inbox, looping through each found email, calling attachments on the email:

START 17.32 MB
  Gmail initialized 17.67 MB
  retrieve inbox 20.43 MB
    email 0: about to read 20.44 MB
    message read 46.55 MB
END 46.55 MB

As I loop though those emails and retrieve the attachments I never get the memory back. :( Here's the script that I'm using: https://gist.github.com/1071169 You'll need to be running Ruby 1.8.7 to use memprof and see all the objects that Ruby is still hanging onto at the end of the script (and it's a LOT, thousands and thousands).

I've tried saving the attachments to disk thinking maybe that'll release the memory, but no luck. Any ideas?

Thanks for any help!
Rob

Moving emails to trash won't work when the account language is different that english

Try switching your account to polish and try to move stuff (delete!) to trash. Won't work. Instead of hardcoding it (message.rb - line 77-78):

trash = @gmail.labels.exist?('[Gmail]/Bin') ? '[Gmail]/Bin' : '[Gmail]/Trash'
move_to(trash) unless %w[[Gmail]/Spam [Gmail]/Bin [Gmail]/Trash].include?(@mailbox.name)

would be nice if you could add a method to manually set trash name (and set Bin/Trash by default).

The work around is quite simple:

mail.delete!
mail.move_to(TRASH_NAME)

Where TRASH_NAME is the localized trash name (for polish it is '[Gmail]/Kosz')

Message#label! raises Gmail::Message::NoLabelError when there's an existing label in different casing

Firstly, thanks for this gem. Your work has saved me a great deal of time.

I've spotted a bug in Message#label!

def label!(name, from=nil)
  label(name, from) 
rescue NoLabelError
  @gmail.labels.add(Net::IMAP.encode_utf7(name))
  label(name, from)
end

When you try to add a label that already exists, but in a different case, you get a Gmail::Message::NoLabelError.

E.g.

[15] pry> email.label!("example")
=> #<struct Net::IMAP::TaggedResponse
 tag="RUBY0060",
 name="OK"...

[17] pry> email.label!("Example")
Gmail::Message::NoLabelError: Label 'Example' doesn't exist! from /Users/stuliston/.rbenv/versions/1.9.3-p286-falcon/lib/ruby/gems/1.9.1/gems/gmail-0.4.0/lib/gmail/message.rb:103:in `rescue in label'

Depending on how you'd like this handled, I'd love to lend a hand in fixing it.

~ Stu

lib fails on connect

So im trying to make a test for my gmail method. this is the error:

Failures:

  1) sendmail method should send an email given a keywords, seeds, and a run_number, 
     Failure/Error: sendmail("hello","there",15)
     NoMethodError:
       undefined method `upcase' on nil:NilClass.
# kernel/delta/kernel.rb:79:in `upcase (method_missing)'
     # /Users/tyler/.rvm/rubies/rbx-head/lib/net/imap.rb:2496:in `text_response'
     # /Users/tyler/.rvm/rubies/rbx-head/lib/net/imap.rb:1994:in `response_untagged'
     # /Users/tyler/.rvm/rubies/rbx-head/lib/net/imap.rb:1950:in `response'
     # /Users/tyler/.rvm/rubies/rbx-head/lib/net/imap.rb:1876:in `parse'
     # /Users/tyler/.rvm/rubies/rbx-head/lib/net/imap.rb:1008:in `get_response'
     # /Users/tyler/.rvm/rubies/rbx-head/lib/net/imap.rb:917:in `initialize'
     # ./lib/mailer.rb:3:in `sendmail'
     # ./spec/mailer_spec.rb:4:in `__script__'
     # kernel/common/eval.rb:120:in `instance_eval'
     # kernel/bootstrap/array.rb:97:in `map'
     # kernel/bootstrap/array.rb:97:in `map'

here is my method
variables in all caps are strings switched out to protect the innocent ;)

def sendmail(keywords,seeds,run_number)
  gmail = Gmail.connect(USERNAME,PASSWORD)

  gmail.deliver do
    to EMAIL_ADDRESS
    subject "new machine run #{run_number}"
    body "machine run is done: keywords: #{keywords} seeds: #{seeds} URL/#{run_number}"
  end
end

How to retreive uid of an email we just sent ?

Hi,

i'm trying to get the uid (the gmail one) of an email I've just sent with the method deliver!

Is it possible to get this info without polling Gmail just after sending ?

Thanks, Alex

determining starred emails in a mailbox

Am i missing some simple way of knowing which emails are starred so i can display accordingly.

So I retrieved those with label "[GMAIL]/Starred" and put their UID's in an array, so i could match UIDs with those in INBOX. However, the same email has a different UID in Starred Label and INBOX label !!!

(I starred the email on the web gmail interface, so i know its the same email).

I am sorry if i am spamming you with these queries since they are not relating to your gem. Any thoughts/tips would be welcome.

How to get contacts

Any way of getting gmail contacts ? I've been searching but nothing shows up, is this outside of IMAP ?

NoMethodError: undefined method `stringify_keys!'

Hello, I have this problem popping up when I try to get message body.
I was able to track it down to message method in message.rb
def message
@message ||= Mail.new(@gmail.mailbox(@mailbox.name) {
@gmail.conn.uid_fetch(uid, "RFC822")[0].attr["RFC822"] # RFC822
})
end

It looks like Mail.new is throwing this error.
fetch returns message body string and Mail.new throws the error.
Any ideas?

Btw. I'm running this on rails 2.3.10, I have these gems installed

mail (2.3.0, 2.2.5)
mime (0.1)
mime-types (1.16)

MANY features broken with Gmail's new "Gmail and Search field Trial

I opted into Gmail's new "Gmail and Search" field trial a few days ago and now anytime I try to move a message to another mailbox, or remove a label, it adds the label, but then immediately moves it to the trash. It does not remove the old label, and any attempt using the gem to remove the trash label or the original label using 'remove_label!' does not work. I know this may not be pertinent now, but if this is a sign that Google is changing their API, it may very much affect this gem.

Saving Attachments

Please excuse me if there's an obvious answer to this as i'm new to rails and github, but I can't seem to find the save_attachments_to method...

Also it seems that the "message" method is private so the attachments saving function isn't implemented in the most recent version of this - correct?

Thanks so much for putting this together and for your help.

Gmail::Message has hard coded label names

gmail has its own special label names such as

"[Gmail]/All Mail",
"[Gmail]/Drafts",
"[Gmail]/Important",
"[Gmail]/Sent Mail",
"[Gmail]/Spam",
"[Gmail]/Starred",
"[Gmail]/Trash"

but these are translated in other language if the gmail language setting is not English.

For an instance, if I set it to Japanese, the labels are listed as below.
*the labels you create will not be affected under in any language setting

"[Gmail]/すべてのメール",
"[Gmail]/ゴミ箱",
"[Gmail]/スター付き",
"[Gmail]/下書き",
"[Gmail]/迷惑メール",
"[Gmail]/送信済みメール",
"[Gmail]/重要"

I am currently using gmail in English to avoid this problem, but could there be a way to add a method to configure this language setting?

Get Email Label

Is it possible to get the labels associated with a Gmail::Message object?

I find a serious lack of documentation on how to handle single emails. Something like:

puts email.subject #prints the email subject

could be useful. I found out the most obvious by trial and error, some other by looking at the source, but this does not make easy to get started. Thanks for your work.

XOAuth2 support

To support XOAuth2 please add to /lib/gmail/client/xoauth2.rb:

require 'gmail_xoauth'

# Usage:
#   gmail = Gmail.connect(:xoauth2, email, :token => token)
module Gmail
  module Client
    class XOAuth2 < Base
      attr_reader :token

      def initialize(username, options={})
        @token           = options.delete(:token)

        super(username, options)
      end

      def login(raise_errors=false)
        @imap and @logged_in = (login = @imap.authenticate('XOAUTH2', username, token)) && login.name == 'OK'
      rescue
        raise_errors and raise AuthorizationError, "Couldn't login to given GMail account: #{username}"        
      end

      def smtp_settings
        [:smtp, {
           :address => GMAIL_SMTP_HOST,
           :port => GMAIL_SMTP_PORT,
           :domain => mail_domain,
           :user_name => username,
           :password => {
             :token           => token
           },
           :authentication => :xoauth2,
           :enable_starttls_auto => true
         }]
      end
    end # XOAuth

    register :xoauth2, XOAuth2
  end # Client
end # Gmail

Could this be used for non GMail accounts?

Hello!

I have to write an email importer that connects to an IMAP account, then gets all unread email, create a new object out of every email, and then sets the emails to "read".

I tried the Mail gem, which seems nice, but it hasn't built-in support for flagging emails as read. So I stumbled over your GMail gem, which seems to use a lot of functionality of the Mail gem.

I'm a bit unsure now whether I should try to add the missed functionality to Mail myself, or whether your GMail gem could be what I need. So - is it possible to use it for other servers than GMail? And why do you think the Mail gem doesn't support so many features that your GMail gem does? Would it be hard to implement those features?

Thank you for your opinion,
Josh

Envelope (only header)

I am writing an ncurses client using gmail gem. Some issues:

  1. When i fetch :all or :unread, the unread status in gmail is changed to read. How to avoid this, since i have only displayed subject to user.

After searching I found that fetching ENVELOPE lets me see headers without resetting UNREAD status. Also, this is fast, compared to normal method. But gmail gem does not support ENVELOPE.

imap.fetch(message_id, "ENVELOPE")[0].attr["ENVELOPE"] 

I would like fetch body only when user clicks on mail, and only then should mail be changed to READ on gmail.

Look forward to your comments.

  1. If i retrieve :all, is there any flag to check for UNREAD. Currently i have to retrieve them in 2 loops, so i can show user which are UNSEEN.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.