rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / Atom feed
* Strange Rack::MailExceptions SMTP connection problem
@ 2010-05-20 21:28 Christoph Helma
  0 siblings, 0 replies; only message in thread
From: Christoph Helma @ 2010-05-20 21:28 UTC (permalink / raw)
  To: rack-devel

[-- Attachment #1: Type: text/plain, Size: 467 bytes --]

I have tried to add Rack::MailExceptions to my Sinatra projects and ran
across a strange problem:

If I include Rack::MailExceptions as in in not_working_config.ru I get
consistent "Connection refused - connect(2)" errors. I am using an
external SMTP server.

A monkeypatch with a verbatim copied send_notification method as in
working_config.ru helps however to get rid of the (authentification?)
problems.

Any ideas what is going on here?

Best regards,
Christoph

[-- Attachment #2: not_working_config.ru --]
[-- Type: application/octet-stream, Size: 449 bytes --]

require 'rubygems'
require 'rack'
require 'rack/contrib'
require 'sinatra'

set :logging, true
set :raise_errors, true 

use Rack::MailExceptions do |mail|
	mail.to 'me@mydomain'
	mail.subject '[ERROR] %s'
	mail.from "myapp@mydomain"
	mail.smtp :server => "myserver", :domain => "mydomain", :port => 587, :authentication => :plain, :user_name => "me@mydomain", :password => "mypassword"
end 

get '/' do
	fail "error!"
end

run Sinatra::Application

[-- Attachment #3: working_config.ru --]
[-- Type: application/octet-stream, Size: 912 bytes --]

require 'rubygems'
require 'rack'
require 'rack/contrib'
require 'sinatra'

set :logging, true
set :raise_errors, true 


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 'me@mydomain'
	mail.subject '[ERROR] %s'
	mail.from "myapp@mydomain"
	mail.smtp :server => "myserver", :domain => "mydomain", :port => 587, :authentication => :plain, :user_name => "me@mydomain", :password => "mypassword"
end 

get '/' do
	fail "error!"
end

run Sinatra::Application

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-05-21  1:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-20 21:28 Strange Rack::MailExceptions SMTP connection problem Christoph Helma

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).