gmailgem / gmail Goto Github PK
View Code? Open in Web Editor NEWA Rubyesque interface to Gmail, with all the tools you'll need.
License: Other
A Rubyesque interface to Gmail, with all the tools you'll need.
License: Other
From @GZhou on November 27, 2010 5:55
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.
Copied from original issue: nu7hatch/gmail#14
From @danijel on September 30, 2011 19:31
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)
Copied from original issue: nu7hatch/gmail#42
From @molsder on April 3, 2011 16:48
Fix for XOAuth SMTP settings. Expands on fix by jonpierce. Includes access token with consumer required for sending messages.
Hi,
I needed this modification to get sending messages to work with XOAuth. I branched it off the v0.4.0 tag.
Regards,
Copied from original issue: nu7hatch/gmail/pull/24
From @cannikin on July 8, 2011 4:51
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
Copied from original issue: nu7hatch/gmail#29
From @slash4 on September 14, 2011 9:46
The example was not working, now it does :)
Copied from original issue: nu7hatch/gmail/pull/40
From @VizirAdmin on May 17, 2011 6:18
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
Copied from original issue: nu7hatch/gmail#25
From @nikosd on August 31, 2011 9:0
Hello there,
Since the gmail_xoauth has support for 2 legged authentication I believe the gmail gem should support it too :)
I couldn't think of way to write actual integration tests but I added some mocked ones and have already tested it on live production code and it seems to be working ok.
Review it and let me know if you have any objections / ideas / etc...
Copied from original issue: nu7hatch/gmail/pull/35
From @bb on November 21, 2010 12:54
Hi Kriss,
here are some additions/fixes for the Gmail project which I needed and which may be useful for others, too.
Cheers,
Ben
Copied from original issue: nu7hatch/gmail/pull/10
From @github0013 on September 29, 2011 2:41
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?
Copied from original issue: nu7hatch/gmail#41
From @rkumar on October 30, 2010 9:11
Any way of getting gmail contacts ? I've been searching but nothing shows up, is this outside of IMAP ?
Copied from original issue: nu7hatch/gmail#5
From @aub on August 16, 2011 16:12
sorry about the whitespace changes in base.rb. the only actual changes are around lines 20, 157, and 199.
Copied from original issue: nu7hatch/gmail/pull/33
From @bb on November 21, 2010 18:57
the title says it all :)
Copied from original issue: nu7hatch/gmail/pull/11
From @myoung8 on December 29, 2010 2:45
Fixed a bug in mailbox.rb so now you can do something like this and it will work:
gmail.inbox.emails(:search => "a string that appears in a message body")
Copied from original issue: nu7hatch/gmail/pull/16
From @rkumar on October 25, 2010 15:16
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)
Copied from original issue: nu7hatch/gmail#1
From @Waseems on June 15, 2011 11:29
Hi,
I have implemented the imap fetch command for range based navigation of the gmail inbox, additionally I have also implemented the read? and starred? flags on the message class.
You might want to be a bit selective about pulling in my changes because I have also for example removed the mailbox locking login for no other reason that it made my application a bit harder to code.
Unfortunately I have not been able to write proper tests because I am assuming that your tests run against a specific mailbox with specific data, as a lot of tests were failing using a clean clone of your repository.
I hope there is something useful in my commits and apologies if I have saddled you up with to much merge hastle :-)
Regards,
Waseem
Copied from original issue: nu7hatch/gmail/pull/27
From @iamwilhelm on February 2, 2011 8:27
I spent a couple hours tracing the error from imap on up, and finally figured out the documentation was wrong in the Readme. :(
Wil
Copied from original issue: nu7hatch/gmail/pull/18
From @beam on February 16, 2011 13:6
working with non-english accounts
Copied from original issue: nu7hatch/gmail/pull/19
From @krusty on July 28, 2011 15:56
Hi, first of all thanks for this great gem. Is there a way to set label colors? does the API even allow this?
Copied from original issue: nu7hatch/gmail#32
From @heaven on January 3, 2012 14:3
Have this problem when trying to use the gem: http://pastebin.com/H9ig0E7P
Not sure if this is a gem problem but perhaps someone know how to fix this issue? Used ruby 1.9.2-p290 patched for faster rails startup.
Fault happens when trying client.logout/inbox, but Gmail.connect(Settings.gmail.username, Settings.gmail.password) works properly.
System is linux x86_64.
Best,
Alex
Copied from original issue: nu7hatch/gmail#46
From @rkumar on October 31, 2010 12:47
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.
Copied from original issue: nu7hatch/gmail#7
From @jerodsanto on October 31, 2010 22:36
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.
Copied from original issue: nu7hatch/gmail#8
From @ducngtuan on February 23, 2011 0:28
Because the last time the change was so big, some small fix cannot be applied. So I make this branch just for it.
Net::IMAP::NoResponseError#new
take a Net::IMAP::TaggedResponse
object as argument, the error description will be put in a Net::IMAP::ResponseText
. A NoMethodError
would be raised for the old code.conn.list('[Gmail]/', '%')
will return nil
, then an error would be raised since we cannot + nil
.Copied from original issue: nu7hatch/gmail/pull/21
From @SixArm on February 23, 2011 1:29
[FIX] spelling of "Urgent" label
Copied from original issue: nu7hatch/gmail/pull/22
From @slash4 on September 9, 2011 17:30
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
Copied from original issue: nu7hatch/gmail#38
From @stefanobernardi on January 1, 2011 18:58
In mailbox.rb it seems you hardcoded the INBOX right? How can I access all the other emails?
Thanks
Copied from original issue: nu7hatch/gmail#17
From @jShaf on October 26, 2010 13:49
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!
Copied from original issue: nu7hatch/gmail#2
From @jgrevich on January 14, 2012 1:21
Copied from original issue: nu7hatch/gmail/pull/50
From @rkumar on October 28, 2010 9:46
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.
Copied from original issue: nu7hatch/gmail#4
From @jnarowski on October 19, 2011 19:50
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.
Copied from original issue: nu7hatch/gmail#43
From @bb on November 21, 2010 21:36
Hi,
the first one is easy: add_label was not doing what the name suggested.
The second one is tough and needs a good review: Labels were outputted utf-7 to the user which is not a good idea, IMHO. I added the standard conversion methods at all places that I saw fitting - hopefully I didn't miss any. So: please review carefully.
I'm just seeing that two older commits are also in this pull request, I hope you don't mind :)
Copied from original issue: nu7hatch/gmail/pull/13
From @miguelgraz on November 12, 2011 2:16
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 =)
Copied from original issue: nu7hatch/gmail#44
From @slash4 on September 12, 2011 17:9
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
Copied from original issue: nu7hatch/gmail#39
From @tjgillies on June 4, 2011 10:0
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
Copied from original issue: nu7hatch/gmail#26
From @bb on November 20, 2010 23:9
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
Copied from original issue: nu7hatch/gmail#9
From @rkumar on October 27, 2010 13:37
I am writing an ncurses client using gmail gem. Some issues:
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.
Copied from original issue: nu7hatch/gmail#3
From @ducngtuan on February 20, 2011 22:2
Sorry, at first I just want to fix some bugs but then I think the design is somehow not very nice. And it turns out that I have done some drastic changes. You don't have to pull all my commits, I just hope you could take a look. Here are what I've done:
It would be difficult to merge all my commits. I have very little experiences in SE so I messed up :">
Copied from original issue: nu7hatch/gmail/pull/20
From @webdevotion on July 19, 2011 10:0
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.
gem list gmail
*** LOCAL GEMS ***
gmail (0.4.0)
gmail_xoauth (0.3.0)
Copied from original issue: nu7hatch/gmail#30
From @saranyan on June 16, 2011 18:9
Hi, in ruby 1.9, there were errors when I tried to use the gem.
internal:prelude:8:in `lock': deadlock; recursive locking (ThreadError)
I traced it to base.rb statement - @mailbox_mutex.synchronize do
This does not make sense to me as it should be a mutex variable. I just made this into mutex variable and the errors went away. Thought this might be useful to others.
thanks!
great Gem. very useful. thanks :)
Copied from original issue: nu7hatch/gmail/pull/28
From @jgrevich on January 13, 2012 5:34
Copied from original issue: nu7hatch/gmail/pull/48
From @bb on November 21, 2010 20:13
Copied from original issue: nu7hatch/gmail/pull/12
From @jonpierce on February 28, 2011 17:24
Copied from original issue: nu7hatch/gmail/pull/23
From @jgrevich on January 9, 2012 6:6
the all method causes an exception when the gmail system folders are hidden from IMAP. I modified the code to handle that case.
Copied from original issue: nu7hatch/gmail/pull/47
From @nu7hatch on August 17, 2011 18:45
Need to figure out how to provide thread safety for this gem... (mentioned here nu7hatch/gmail#28)
Copied from original issue: nu7hatch/gmail#34
From @rkumar on October 31, 2010 6:3
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.
Copied from original issue: nu7hatch/gmail#6
From @jgrevich on January 13, 2012 5:36
Copied from original issue: nu7hatch/gmail/pull/49
From @stefanobernardi on December 10, 2010 16:12
Is it possible to do this through oauth and not have to ask email and pass?
Thanks
Copied from original issue: nu7hatch/gmail#15
From @webdevotion on July 19, 2011 10:39
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
Copied from original issue: nu7hatch/gmail#31
From @syntaxTerr0r on September 4, 2011 3:36
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
Copied from original issue: nu7hatch/gmail#36
From @alexgenco on November 23, 2011 1:7
The diff pretty much explains it. STDERR.puts e.message
fails with undefined method
message' for nil:NilClassbecause e isn't assigned in the rescue clause. Changed it to
rescue LoadError => e`
Copied from original issue: nu7hatch/gmail/pull/45
From @syntaxTerr0r on September 4, 2011 15:16
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.
Copied from original issue: nu7hatch/gmail#37
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.