Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

mail instead of tmail in mailexceptions #42

Closed
wants to merge 2 commits into from

4 participants

@bratke

Hi,

I migrated mailexceptions to require mail instead of tmail.
2 reasons:

  • tmail just did not seem to work on my setup (ruby 1.9.2, sinatra, 64-bit arch)
  • Mikel Lindsaar suggests this replacement (http://tmail.rubyforge.org/) I also fixed one failing test.

what i didn't:

  • gemspec is untouched

Regards,
L. Bratke

@ioquatix

This seems like a great patch... why hasn't it been integrated?

@rkh
Owner

Because rack-contrib is currently not maintained.

@ioquatix

Okay so do you need a maintainer?

@rkh
Owner

I guess so. You should talk to @rtomayko if you are interested.

@ioquatix

Okay, great, thanks @rkh.

@rtomayko I'm talking to you now it seems :helicopter:

@rkh
Owner

If you rebase, I will merge.

@mpalmer
Owner

Closing this PR in favour of #65, which appears to be a superset of this one.

@mpalmer mpalmer closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 14, 2011
  1. mailexceptions migrated from tmail to mail

    Ludwig Bratke authored
  2. fixed test/spec_rack_mailexceptions.rb

    Ludwig Bratke authored
This page is out of date. Refresh to see the latest.
View
11 lib/rack/contrib/mailexceptions.rb
@@ -1,5 +1,5 @@
require 'net/smtp'
-require 'tmail'
+require 'mail'
require 'erb'
module Rack
@@ -53,14 +53,14 @@ def smtp(settings={})
private
def generate_mail(exception, env)
- mail = TMail::Mail.new
+ mail = Mail.new
mail.to = Array(config[:to])
mail.from = config[:from]
mail.subject = config[:subject] % [exception.to_s]
mail.date = Time.now
- mail.set_content_type 'text/plain'
mail.charset = 'UTF-8'
- mail.body = @template.result(binding)
+ text_body = @template.result(binding)
+ mail.text_part = Mail::Part.new { body text_body }
mail
end
@@ -81,7 +81,7 @@ def send_notification(exception, env)
server.start smtp[:domain], smtp[:user_name], smtp[:password], smtp[:authentication]
mail.to.each do |recipient|
- server.send_message mail.to_s, mail.from, recipient
+ server.send_message mail.to_s, mail.from.first, recipient
end
end
@@ -130,3 +130,4 @@ def extract_body(env)
end
end
+
View
6 test/spec_rack_mailexceptions.rb
@@ -62,8 +62,10 @@ def test_exception
tmail.from.should.equal ['bar@example.org']
tmail.subject.should.equal '[ERROR] Suffering Succotash!'
tmail.body.should.not.be.nil
- tmail.body.should.be =~ /FOO:\s+"BAR"/
- tmail.body.should.be =~ /^\s*THE BODY\s*$/
+
+ body = tmail.body.parts.first.body
+ body.should.be =~ /FOO:\s+"BAR"/
+ body.should.be =~ /^\s*THE BODY\s*$/
end
specify 'catches exceptions raised from app, sends mail, and re-raises' do
Something went wrong with that request. Please try again.