summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/config/config_ru.rb38
1 files changed, 30 insertions, 8 deletions
diff --git a/lib/config/config_ru.rb b/lib/config/config_ru.rb
index 09fba3b..8de82cb 100644
--- a/lib/config/config_ru.rb
+++ b/lib/config/config_ru.rb
@@ -18,11 +18,33 @@ set :raise_errors, true
end
use Rack::ShowExceptions
-#if MAIL
-# use Rack::MailExceptions do |mail|
-# mail.to 'helma@in-silico.ch'
-# mail.subject '[ERROR] %s'
-# mail.from "toxcreate@in-silico.ch"
-# mail.smtp MAIL
-# end
-#end
+if MAIL
+
+ # monkeypatch with the original method
+ # strangely enough my mailserver returns "Connection refused - connect(2)" errors without this patch
+ module Rack
+ class MailExceptions
+
+ def send_notification(exception, env)
+ mail = generate_mail(exception, env)
+ smtp = config[:smtp]
+ env['mail.sent'] = true
+ return if smtp[:server] == 'example.com'
+
+ Net::SMTP.start smtp[:server], smtp[:port], smtp[:domain], smtp[:user_name], smtp[:password], smtp[:authentication] do |server|
+ mail.to.each do |recipient|
+ server.send_message mail.to_s, mail.from, recipient
+ end
+ end
+ end
+ end
+ end
+
+
+ use Rack::MailExceptions do |mail|
+ mail.to 'helma@in-silico.ch'
+ mail.subject '[ERROR] %s'
+ mail.from "toxcreate@in-silico.ch"
+ mail.smtp MAIL
+ end
+end