*** log.rb.org 2011-11-29 07:48:06.578720850 +0100 --- log.rb 2011-11-29 07:46:47.059288927 +0100 *************** *** 6,12 **** require 'config' require 'cgi' require 'date' ! require 'tmail' module ODDB class Log --- 6,12 ---- require 'config' require 'cgi' require 'date' ! require 'mail' module ODDB class Log *************** *** 39,45 **** subject, (@date_str || @date.strftime('%m/%Y')), ].compact.join(' - ') ! text = text_part(@report) parts = @parts.nil? ? [] : @parts.dup --- 39,45 ---- subject, (@date_str || @date.strftime('%m/%Y')), ].compact.join(' - ') ! text = text_part(@report) parts = @parts.nil? ? [] : @parts.dup *************** *** 62,72 **** outgoing = if(parts.empty?) text else ! multipart = TMail::Mail.new multipart.parts << text parts.each { |mime, name, content| ! mtype, stype = mime.split('/') ! multipart.parts << file_part(mtype, stype, name, content) } multipart end --- 62,71 ---- outgoing = if(parts.empty?) text else ! multipart = Mail.new multipart.parts << text parts.each { |mime, name, content| ! multipart.attachments[name] = {:mime_type => mime, :content => content} } multipart end *************** *** 87,97 **** send_mail(outgoing) end def notify_attachment(attachment, headers) ! multipart = TMail::Mail.new subject = headers[:subject] multipart.parts << text_part(subject) ! type1, type2 = (headers[:mime_type] || 'text/plain').split('/') ! multipart.parts << file_part(type1, type2, headers[:filename], attachment) multipart.from = @mail_from || self::class::MAIL_FROM @recipients = (@recipients + self::class::MAIL_TO).uniq multipart.to = @recipients --- 86,98 ---- send_mail(outgoing) end def notify_attachment(attachment, headers) ! multipart = Mail.new subject = headers[:subject] multipart.parts << text_part(subject) ! mime = (headers[:mime_type] || 'text/plain') ! multipart.attachments[headers[:filename]] = {:mime_type => mime, :content => attachment} ! # This is also fine. but the full file path is necessary ! #multipart.add_file('/home/masa/work/test.xls') multipart.from = @mail_from || self::class::MAIL_FROM @recipients = (@recipients + self::class::MAIL_TO).uniq multipart.to = @recipients *************** *** 101,109 **** send_mail(multipart) end def text_part(body) ! text = TMail::Mail.new ! text.set_content_type('text', 'plain', 'charset'=>'UTF-8') ! text.body = body text end def send_mail(multipart) --- 102,109 ---- send_mail(multipart) end def text_part(body) ! text = Mail::Part.new ! text.body = body text end def send_mail(multipart) *************** *** 130,142 **** } } end - def file_part(type1, type2, filename, attachment) - file = TMail::Mail.new - file.set_content_type(type1, type2, 'name' => filename) - file.disposition = 'attachment' - file.transfer_encoding = 'base64' - file.body = [attachment].pack('m') - file - end end end --- 130,134 ----