Skip to content

Commit

Permalink
Disabled SSL validation for 1.9
Browse files Browse the repository at this point in the history
Improved imap_archive and imap_keywords --list speed

[git-p4: depot-paths = "//src/imap_processor/dev/": change = 4966]
  • Loading branch information
drbrain committed May 22, 2009
1 parent 86c6c28 commit a232e58
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
11 changes: 11 additions & 0 deletions History.txt
@@ -1,3 +1,14 @@
=== 1.2 / 2009-05-??

* 1 major enhancement
* imap_archive which archives old mail to dated mailboxes

* N minor enhancements
* Added IMAPProcessor#create_mailbox
* Added IMAPProcessor#delete_messages
* Added IMAPProcessor#move_messages
* Disabled verification of SSL certs for 1.9

=== 1.1.1 / 2009-05-19

* 1 bug fix
Expand Down
10 changes: 6 additions & 4 deletions lib/imap_processor.rb
Expand Up @@ -308,7 +308,7 @@ def initialize(options)
# Returns a Connection object.

def connect(host, port, ssl, username, password, auth = nil)
imap = Net::IMAP.new host, port, ssl
imap = Net::IMAP.new host, port, ssl, nil, false
log "Connected to imap://#{host}:#{port}/"

capability = imap.capability
Expand Down Expand Up @@ -438,7 +438,8 @@ def mime_parts(uids, mime_type)
end

##
# Create the specified mailbox if it doesn't exist
# Create the mailbox +name+ if it doesn't exist. Note that this will SELECT
# the mailbox if it exists.

def create_mailbox name
begin
Expand All @@ -451,7 +452,7 @@ def create_mailbox name
end

##
# Delete and expunge the specified uids.
# Delete and +expunge+ the specified +uids+.

def delete_messages uids, expunge = true
log "DELETING [...#{uids.size} uids]"
Expand All @@ -463,7 +464,8 @@ def delete_messages uids, expunge = true
end

##
# Move the specified uids to a new destination and delete them.
# Move the specified +uids+ to a new +destination+ then delete and +expunge+
# them.

def move_messages uids, destination, expunge = true
return if uids.empty?
Expand Down
14 changes: 4 additions & 10 deletions lib/imap_processor/archive.rb
Expand Up @@ -85,18 +85,12 @@ def run
def show_messages(uids)
return unless list

responses = imap.fetch uids, [
'BODY.PEEK[HEADER]',
'FLAGS'
]
fetch_data = 'BODY.PEEK[HEADER.FIELDS (DATE SUBJECT MESSAGE-ID)]'
responses = imap.fetch uids.first, fetch_data
fetch_data.sub! '.PEEK', '' # stripped by server

responses.each do |res|
header = res.attr['BODY[HEADER]']

puts header[/^Date: .*/i]
puts header[/^Subject: .*/i]
puts header[/^Message-Id: .*/i]
puts
puts res.attr[fetch_data]
end
end
end
Expand Down
7 changes: 3 additions & 4 deletions lib/imap_processor/keywords.rb
Expand Up @@ -134,15 +134,14 @@ def show_messages(uids)
return unless @list

responses = @imap.fetch uids, [
'BODY.PEEK[HEADER]',
Net::IMAP::RawData.new('BODY.PEEK[HEADER.FIELDS (SUBJECT MESSAGE-ID)]'),
'FLAGS'
]

responses.each do |res|
header = res.attr['BODY[HEADER]']
header = res.attr['BODY[HEADER.FIELDS (SUBJECT MESSAGE-ID)]']

puts header[/^Subject: .*/i]
puts header[/^Message-Id: .*/i]
puts header.chomp

flags = res.attr['FLAGS'].map { |flag| flag.inspect }.join ', '

Expand Down

0 comments on commit a232e58

Please sign in to comment.