問題 例外を吐くと ....This is the Postfix program at host snares.example.com. : The Postfix program >test@example.com< : Command died with status 1: "/var/MailApp/mailserver/test.rb". Command output: /usr/lib/ruby/1.8/logger.rb:518:in `initialize': Permission denied - /var/MailApp/mailserver/../log/MailServer.log (Errno::EACCES) from /usr/lib/ruby/1.8/logger.rb:518:in `open' from /usr/lib/ruby/1.8/logger.rb:518:in `open_logfile' from ユーザー宛にエラーメール
32.
app\models\schdule_mail_receiver.rb class SchduleMailReceiver< ActionMailer::Base def receive(email) begin email.each_header{|name,value| : rescue => ex bt = ex.backtrace logger.fatal "\n !!!!!!!!!!!!!!!!!!!!!!\nexception caught:\n" logger.fatal "#{bt.shift}: #{ex.message} (#{ex.class})" logger.fatal bt.map{|s| "\tfrom #{s}"}.join("\n") logger.fatal "\n !!!!!!!!!!!!!!!!!!!!!!\n\n" end 対策:例外は出さない。
33.
def error_catch logger= ActiveRecord::Base.logger begin yield rescue => ex bt = ex.backtrace logger.fatal "\n !!!!!!!!!!!!!!!!!!!!!!\nexception caught:\n" logger.fatal "#{bt.shift}: #{ex.message} (#{ex.class})" logger.fatal bt.map{|s| "\tfrom #{s}"}.join("\n") logger.fatal "\n !!!!!!!!!!!!!!!!!!!!!!\n\n" end end error_catch{ 普通の処理 }
require 'net/pop' task:mail_fetcher => [:environment] do @config = YAML.load(IO.read("#{RAILS_ROOT}/config/mail_fetcher.yml")) daemonize() loop do pop = Net::POP3.new(@config[RAILS_ENV]['server']) pop.start(@config[RAILS_ENV]['username'], @config[RAILS_ENV]['password']) unless pop.mails.empty? pop.each_mail do |m| IncomingMailHandler.receive(m.pop) m.delete end end pop.finish sleep(SLEEP_TIME) end end
メイドめーる : http://www.maidmail.jp/ Drecom Award on rails 2008 : http://rails.drecom.jp/ 夢夢色 TOWN : http://www.poipoi.com/yakko/index.html Rails でのメール処理に関するサイト Stress-free Incoming E-Mail Processing with Rails http://railspikes.com/2007/6/1/rails-email-processing GCalAPI に関するサイト RubyForge: google calendar api: Project Info : http://rubyforge.org/projects/gcalapi/ メールから Google Calendar に登録するサンプル http://d.hatena.ne.jp/zorio/20060925/1159201438 Google カレンダー API に関するサイト Google Calendar API の基礎 : Under Construction, Baby : http://www.rcdtokyo.com/ucb/contents/i000815.php ↑ PHP ですけど、流れがとてもわかりやすくまとまっています。オススメ。 API Developer's Guide: The Protocol - Google Calendar APIs and Tools - Google Code : http://code.google.com/intl/ja/apis/calendar/docs/2.0/developers_guide_protocol.html Mextractr に関するサイト Mextractr メタデータ抽出エンジン : http://api.emetadata.net/doc RubyForge: mextractr_webapi: Project Info : http://rubyforge.org/projects/mextractr/ GoogleAuthSub に関するサイト [ruby]gcalapi を使って AuthSub ログイン http://blog.mogya.com/2008/09/rubygcalapiauthsub.html [ruby]GoogleAuthSub を使う http://blog.mogya.com/2008/09/googleauthsub.html AuthSub Authentication for Web Applications - Account Authentication API - Google Code : http://code.google.com/apis/accounts/docs/AuthSub.html 興味を持っていただいた方のための URL :