def add_attachment(filename, type=nil, attachmentheaders = nil)
attachment = Hash.new()
attachment['filename'] = Pathname.new(filename).basename
if(type == nil)
attachment['mimetype'] = MIME::Types.type_for(filename).to_s
else
attachment['mimetype'] = type
end
File.open(filename, "rb") { |fp|
attachment['attachment'] = file_encode(fp.read())
}
if(attachmentheaders != nil)
if(!attachmentheaders.kind_of?(Array))
attachmentheaders = attachmentheaders.split(/\r?\n/)
end
attachment['headers'] = attachmentheaders
end
@attachments << attachment
end