Changeset 31447 for platform/pragger

Show
Ignore:
Timestamp:
03/22/09 22:32:11 (5 years ago)
Author:
niku
Message:

support like feed item

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • platform/pragger/Publish/send_mail_by_gmail.rb

    r31371 r31447  
    4242} 
    4343 
    44 def build_mail(config, data) 
     44def build_mail(config, contents) 
    4545  return <<"EndOfMail".tojis 
    4646From: #{config['from_addr']} 
    4747To: #{config['to_addrs'].join(', ')} 
    48 Subject: #{data['subject']} 
    49 Date: #{data['date']} 
     48Subject: #{contents[:subject]} 
     49Date: #{contents[:date]} 
    5050Content-Type: text/plain; charset=ISO-2022-JP 
    5151 
    52 #{data['body']} 
     52#{contents[:body]} 
    5353EndOfMail 
    5454end 
     
    5757  raise if config['account'].nil? || config['password'].nil? || config['to_addrs'].nil? 
    5858   
    59   config['date'] ||= DEFAULT['date'] 
    6059  config['address'] ||= DEFAULT['address'] 
    6160  config['port'] ||= DEFAULT['port'] 
     
    6867  Net::SMTP.start(config['address'], config['port'], config['helo_domain'], config['account'], config['password'], config['authtype']) do |smtp| 
    6968    data.each do |d| 
    70       smtp.send_mail(build_mail(config, d), config['from_addr'], config['to_addrs']) 
     69      # like RSS::RDF::Item ? 
     70      if (d.respond_to? :title) && (d.respond_to? :description) && (d.respond_to? :date) 
     71        contents = {:subject => d.title, :date => d.date,:body => d.description} 
     72      else 
     73        contents = {:subject => d['subject'], :date => (d['date'] || DEFAULT['date']), :body => d['body']} 
     74      end 
     75      smtp.send_mail(build_mail(config, contents), config['from_addr'], config['to_addrs']) 
    7176      sleep config['waiting_time'] 
    7277    end