def send_error_mail(exception)
if Module.constants.include?("ERROR_MAIL_TO")
host = Keystone::Os.get()
title = %|error occur at "#{host.hostname}" [#{error.message}]|
mail_to = ERROR_MAIL_TO
mail_to = [mail_to] if mail_to.is_a?(String)
mail_from = Module.constants.include?("ERROR_MAIL_FROM") ? ERROR_MAIL_FROM : mail_to[0]
smtp_addr = Module.constants.include?("ERROR_MAIL_STMP_ADDR") ? ERROR_MAIL_STMP_ADDR : '127.0.0.1'
smtp_port = Module.constants.include?("ERROR_MAIL_STMP_PORT") ? ERROR_MAIL_STMP_PORT : 25
body = "==== error message ====\n\#{exception.message}\n====== backtrace ======\n\#{exception.backtrace.join(\"\\n\")}\n===== environment =====\n\#{host.dump}\n"
Keystone::Mail::Send.send(mail_from,mail_to,title,body,smtp_addr,smtp_port)
end
end