Skip to content

Commit fbd9ae7

Browse files
committed
README
1 parent 372c118 commit fbd9ae7

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

README.md

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
# Net::Imap
1+
# Net::IMAP
22

3-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/net/imap`. To experiment with that code, run `bin/console` for an interactive prompt.
4-
5-
TODO: Delete this and the text above, and describe your gem
3+
Net::IMAP implements Internet Message Access Protocol (IMAP) client
4+
functionality. The protocol is described in [IMAP].
65

76
## Installation
87

@@ -22,7 +21,33 @@ Or install it yourself as:
2221

2322
## Usage
2423

25-
TODO: Write usage instructions here
24+
### List sender and subject of all recent messages in the default mailbox
25+
26+
```ruby
27+
imap = Net::IMAP.new('mail.example.com')
28+
imap.authenticate('LOGIN', 'joe_user', 'joes_password')
29+
imap.examine('INBOX')
30+
imap.search(["RECENT"]).each do |message_id|
31+
envelope = imap.fetch(message_id, "ENVELOPE")[0].attr["ENVELOPE"]
32+
puts "#{envelope.from[0].name}: \t#{envelope.subject}"
33+
end
34+
```
35+
36+
### Move all messages from April 2003 from "Mail/sent-mail" to "Mail/sent-apr03"
37+
38+
```ruby
39+
imap = Net::IMAP.new('mail.example.com')
40+
imap.authenticate('LOGIN', 'joe_user', 'joes_password')
41+
imap.select('Mail/sent-mail')
42+
if not imap.list('Mail/', 'sent-apr03')
43+
imap.create('Mail/sent-apr03')
44+
end
45+
imap.search(["BEFORE", "30-Apr-2003", "SINCE", "1-Apr-2003"]).each do |message_id|
46+
imap.copy(message_id, "Mail/sent-apr03")
47+
imap.store(message_id, "+FLAGS", [:Deleted])
48+
end
49+
imap.expunge
50+
```
2651

2752
## Development
2853

@@ -32,5 +57,5 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
3257

3358
## Contributing
3459

35-
Bug reports and pull requests are welcome on GitHub at https://github.com/hsbt/net-imap.
60+
Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/net-imap.
3661

0 commit comments

Comments
 (0)