easy_imap

DESCRIPTION:

A simple interface to proccessing e-mail messages using IMAP, including handling multipart messages and attachments.

SYNOPSIS:

Create a connection using EasyIMAP::Server.connect, and with the connection you can access Folders and Messages. To get a list of all Folders use EasyIMAP::Server#folders, to access the messages in a folder use EasyIMAP::Folder#messages, and to access the Attachments on a Message use EasyIMAP::Message#attachments.

EasyIMAP::Server.connect('mail.example.com', :username => 'username, :password => 'password) do |conn|
  inbox = conn.folders.first
  inbox.messages.each do |m|
    if m.attachments.any? && m.attachments.first.content_type == "application/vnd.ms-excel"
      File.open("/tmp/first_attachment.xls", "w") do |f|
        f.write(m.attachments.first.body)
      end
    end
  end
end

REQUIREMENTS:

  • tmail, 1.2.3.1

INSTALL:

  • sudo gem install easy_imap

CONTRIBUTORS:

EasyIMAP would not be nearly as wonderful without the contributions of others. I could not have done it myself. Thank you to all the contributors!

  • Paul Stadig (pjstadig)

  • Mark Lussier (intabulas)

  • Guillaume Dorchies

LICENSE:

(The MIT License)

Copyright © 2008 Paul Stadig

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.