Mail Lib
An mail parsing lib.
== Features
== 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.content = {: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.content = {
:text_plain => "Hallo World !!!",
: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.content = {
:text_plain => "Hallo World !!!",
: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.type => "image/tiff"
puts attachment.header.content_disposition.filename => "fax.tif"
puts attachment.size => 408850
end
end