r38y / postmark-rails3

Postmark gem for Rails3
http://postmarkapp.com
MIT License
4 stars 1 forks source link

From field return Mail::AddressContainer #3

Open mech opened 14 years ago

mech commented 14 years ago

I tried to send email and am getting this conversion error:

Postmark::InvalidMessageError: Error parsing 'From': Illegal email address ']'. It must contain the '@' symbol.

m = LeaveMailer.reject_leave("xx@ibm.com)
m.from #=> ["yy@ibm.com"]

I did specify a String for the "From" part. It is returning me an Mail::AddressContainer and Postmark gem tried to convert it to string with to_s. Any idea? My code is as follow:

class LeaveMailer < ActionMailer::Base
  def reject_leave(email)
    mail(:from => "yy@ibm.com", :to => email)
  end
end
mech commented 14 years ago

I go and modified the protected convert_mail method to take the first array element and it works:

def convert_mail(message)
  options = { "From" => message.from.first.to_s, "Subject" => message.subject }
r38y commented 14 years ago

Are you using this in conjunction with my fork of postmark-gem, both installed as plugins? This code is going to get pulled into the wildbit/postmark-rails gem at some point soon.

mech commented 14 years ago

Yes, I am using this together with your fork of Postmark gem. I am not using plugin however, but I believe it does not matter. I use these in my Gemfile:

gem 'postmark', :git => 'git://github.com/r38y/postmark-gem.git', :branch => 'master'
gem 'postmark-rails', :git => 'git://github.com/r38y/postmark-rails3.git', :branch => 'master'
r38y commented 14 years ago

OK, I'll take a look.