[ANN] gmailer 0.0.3

P

Park Heesob

GMailer is a class for interface to Google's webmail service.

It can fetch mails, save attachements, get cotact lists, invite someone
or send message with file attachments. You can make GMail as an online
backup system or as a virtual filesystem with this library.

Now usage is very simple and compact like this:

GMailer.connect(name,pwd) do |g|
#fetch
g.fetch:)label=>"my_label") {|snapshot|
puts "Total # of conversations of my_label = " +
snapshot.box_total.to_s
}

#get contact
g.fetch:)contact=>"freq").each do |item|
puts "Name: #{item['name']} Email: #{item['email']}"
end

#send
g.send(
:to => "(e-mail address removed)",
:subj => "Hello There!",
:body => "Hi...\n\nBlah blah blah~...",
:files => ["./test.txt"]
)

# get labels
labels = g.get_labels

# get messages
g.get_messages:)label=>labels[0]).each {|m|
puts "Subject: #{m['subj']} / Snippet: #{m['snippet']}" if m['new?']
}
end

Now you can connect with proxy server like this

GMailer.connect:)username=>name,:password=>pwd,
:proxy_host=>proxy,:proxy_port=>8080,
:proxy_user=>user,:proxy_pass=>pass) { |g|
...
}

But proxy connection needs some tests.

Project:: http://rubyforge.org/projects/gmailutils/
Bugs:: http://rubyforge.org/tracker/?group_id=869


Regards,

Park Heesob
 
J

James Britt

Park said:
GMailer is a class for interface to Google's webmail service.

It can fetch mails, save attachements, get cotact lists, invite someone
or send message with file attachments. You can make GMail as an online
backup system or as a virtual filesystem with this library.

Thanks, very nice.

Do you plan on releasing this as a gem?

James

--

http://www.ruby-doc.org - The Ruby Documentation Site
http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys
 
J

James Britt

Park said:
GMailer is a class for interface to Google's webmail service.

It can fetch mails, save attachements, get cotact lists, invite someone
or send message with file attachments. You can make GMail as an online
backup system or as a virtual filesystem with this library.
...
I was just trying out a variation of your example, and got an error at
line 305 of gmailer.rb.

q = "search=cat&cat=" + box + "&view=tl&start=" + pos.to_s

'box', it seems, might be nil. So I added a call to to_s


q = "search=cat&cat=" + box.to_s + "&view=tl&start=" + pos.to_s



Also, two suggestions for a very cool library (and thanks for writing it):

Remove the camelCase names and break code early before people start
building dependencies. (I'm not convinced that simply aliasing these
names is a good solution.)

Replace the cryptic parameters ( e.g. :mid, :tid, :eek:rig_df ) with
something readable. Even :subj should be :subject.

Thanks again for your efforts!


James

--

http://www.ruby-doc.org - The Ruby Documentation Site
http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys
 
S

Shashank Date

Hi Park,


=20
Now you can connect with proxy server like this
=20
GMailer.connect:)username=3D>name,:password=3D>pwd,
:proxy_host=3D>proxy,:proxy_port=3D>8080,
:proxy_user=3D>user,:proxy_pass=3D>pass) { |g|
...
}
=20
But proxy connection needs some tests.
=20

I tested it with both with and without proxy. On Win 2K Pro and=20
ruby 1.8.2 (2004-12-25) [i386-mswin32] it error'd on the following=20
code, in both cases (different errors):

#-------------------------

require "gmailer"

name =3D "stdate"
pwd =3D gets=20
proxy =3D "firewall.corp.proxy.com"

GMailer.connect(name,pwd) do |g|

# Now you can connect with proxy server like this
# GMailer.connect:)username=3D>name,:password=3D>pwd,
# :proxy_host=3D>proxy,:proxy_port=3D>80) do |g|
#:proxy_user=3D>user,:proxy_pass=3D>pass)=20
=20
puts "------ fetch"
g.fetch:)label=3D>"my_label") {|snapshot|
puts "Total # of conversations of my_label =3D " + snapshot.box_t=
otal.to_s
}

puts "------ get contact"
g.fetch:)contact=3D>"freq").each do |item|
puts "Name: #{item['name']} \nEmail: #{item['email']}"
end

puts "------ send"
g.send(
:to =3D> "(e-mail address removed)",
:subj =3D> "Hello There!",
:body =3D> "Hi...\n\nBlah blah blah~...",
:files =3D> ["./junk.jpeg"]
)

puts "------ get labels"
labels =3D g.get_labels
p labels

puts "------ get messages"
g.get_messages:)label=3D>labels[0]).each {|m|
puts "Subject: #{m['subj']} / Snippet: #{m['snippet']}" if m['new?']
}
end

__END__

#------------------------------------------------------------------------=
--

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Here is the transcript with Proxy:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
C:\atest>ruby tst_gmailer3.rb
my password here :)
c:/ruby/lib/ruby/1.8/net/protocol.rb:83:in `initialize': getaddrinfo: ser=
vname not supported for
ai_socktype. (SocketError)
from c:/ruby/lib/ruby/1.8/net/protocol.rb:83:in `new'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:83:in `connect'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:82:in `timeout'
from c:/ruby/lib/ruby/1.8/timeout.rb:55:in `timeout'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:82:in `connect'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:64:in `initialize'
from c:/ruby/lib/ruby/site_ruby/1.8/net/protocols.rb:37:in `initi=
alize'
from c:/ruby/lib/ruby/1.8/net/http.rb:430:in `open'
from c:/ruby/lib/ruby/1.8/net/http.rb:430:in `do_start'
from c:/ruby/lib/ruby/1.8/net/http.rb:419:in `start'
from c:/ruby/lib/ruby/site_ruby/1.8/gmailer.rb:148:in `connectNoC=
ookie'
from c:/ruby/lib/ruby/site_ruby/1.8/gmailer.rb:217:in `connect'
from tst_gmailer3.rb:10

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
And here without proxy:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

C:\atest>ruby tst_gmailer3.rb
my password here :)
------ fetch
Total # of conversations of my_label =3D 0
------ get contact
Name: shanko_date
Email: (e-mail address removed)
Name: shashank
Email: (e-mail address removed)
------ send
------ get labels
[]
------ get messages
c:/ruby/lib/ruby/site_ruby/1.8/gmailer.rb:305:in `+': cannot convert nil =
into String (TypeError)
from c:/ruby/lib/ruby/site_ruby/1.8/gmailer.rb:305:in `fetchBox'
from c:/ruby/lib/ruby/site_ruby/1.8/gmailer.rb:379:in `fetch'
from c:/ruby/lib/ruby/site_ruby/1.8/gmailer.rb:502:in `get_messag=
es'
from tst_gmailer3.rb:37
from tst_gmailer3.rb:7:in `connect'
from tst_gmailer3.rb:7

C:\atest>

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
HTH,
-- shanko



__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around=20
http://mail.yahoo.com=20
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

[ANN] gmailer-0.0.5 0
[ANN] gmailer 0.0.9 2
[ANN] gmailer-0.0.8 released 8
[ANN] gmailer-0.0.7 2
[ANN] gmailer 0.1.0 3
[ANN] gmailer 0.0.1 (plain text) 5
[ANN] gmailer-0.0.2 2
gmailer problems. 2

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top