drewblas/aws-ses

Error when calling deliver!

fedegl opened this issue · 11 comments

When using the deliver! method (with a bang), The mail gem throws a "You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.[]"

This is because the delivery_method used by action mailer (This is a AWS::SES::Base instance) tries to do this:

    def deliver!
      response = delivery_method.deliver!(self)
      inform_observers
      delivery_method.settings[:return_response] ? response : self
    end

And because the delivery_method.settings is nil, it returns the error when trying to access the array. Maybe the AWS::SES::Base settings accessor should be initialized with an empty array.

+1 I just humbly confirm the problem.
--Frank

Yep, I am having this issue, too.

+1 We're having this issue, handled with:

any_instance_of(AWS::SES::Base, settings: {})

but obviously that's just for testing and it's annoying...

+1

Looks like this was caused by changes to Mail 2.2.16: mikel/mail@2.2.14...2.2.16#diff-14

Try using Mail 2.2.14 or 2.2.15, if possible.

Works for me too, thank you a lot!
--Frank

+1

Can we merge fedegl's commit in?

Its a good idea. @fedegl commit worked for me too.

I created a pull request for this that is the @fedegl fix without the whitespace issues. I thought it would show up here.

#27

+1 for this new pull request, please! It won't work in Rails 3.1 without it.