easy_imap
What
A simple interface to proccessing e-mail messages using IMAP, including handling multipart messages and attachments.
Installing
sudo gem install easy_imap
Requirements
- tmail, 1.2.3.1
Demonstration of usage
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
For more details, see the RDocs.
How to submit patches
Read the 8 steps for fixing other people’s code.
You can fetch the source from:
git clone git://github.com/pjstadig/easy_imap.git
Build and test instructions
cd easy_imap rake test rake install_gem
License
This code is free to use under the terms of the MIT license.
Contact
Comments are welcome. Send an email to paul@stadig.name.
Paul Stadig, 20th November 2009
Theme extended from Paul Battley