Mail Lib
An mail parsing lib.
== Features
- clean API
- fast mail parsing
== Installation
gem sources -a http://gems.github.com
sudo gem install aklaiber-mail
== Usage
Create new Mail
mail = Mail::Mail.new
mail.header.to = "test_to@test.de"
mail.header.from = "test_from@test.de"
mail.header.subject = "Test Mail"
mail.header.content_transfer_encoding = "quoted-printable"
mail.header.content_type = {charset => "UTF-8"}
mail.add_part("text/plain", "Hallo World !!!")
Create new Mail with Text and HTML part
mail = Mail::Mail.new
mail.header.to = "test_to@test.de"
mail.header.from = "test_from@test.de"
mail.header.subject = "Test Mail"
mail.header.content_transfer_encoding = "quoted-printable"
mail.header.content_type(:charset) = "UTF-8"
mail.add_part("text/plain", "Hallo World !!!")
mail.add_part("text/html", "<strong>Hallo World !!!</strong>")
Create new Mail Attachment
mail = Mail::Mail.new
mail.header.to = "test_to@test.de"
mail.header.from = "test_from@test.de"
mail.header.subject = "Test Mail"
mail.header.content_transfer_encoding = "quoted-printable"
mail.header.content_type(:charset) = "UTF-8"
mail.add_part("text/plain", "Hallo World !!!")
mail.add_part("image/jpeg", File.read("path/to/image"))
Load an existing Mail
mail = Mail::Mail.new(File.read("path/to/mail"))
puts mail.header.to => ["test_to@test.de"]
Get attachments from a Mail
mail = Mail::Mail.new(File.read("path/to/mail"))
if mail.header.attachments?
mail.attachments do |attachment|
puts attachment.header.content_type(:main) => "image/tiff"
puts attachment.header.content_disposition(:filename) => "fax.tif"
puts attachment.size => 408850
end
end