# Understanding ActionMailer::Base.new

**URL:** <https://www.ruby-forum.com/t/understanding-actionmailer-base-new/134300>\
**Category:** Rails\
**Created:** [April 9, 2008, 5:49pm UTC](https://www.ruby-forum.com/t/understanding-actionmailer-base-new/134300 "2008-04-09T17:49:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gbh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/9fc348/32.png) [@gbh](https://www.ruby-forum.com/u/gbh)\
**Post date:** [April 9, 2008, 5:49pm UTC](https://www.ruby-forum.com/t/understanding-actionmailer-base-new/134300/1 "2008-04-09T17:49:29Z")

</div>

While writing a small plugin I stumbled upon this strangeness. I have  
TMail objects stored in database for process that sends them out  
whenever needed.

Obvious way of sending them out would be calling  
ActionMailer::Base.deliver(my\_mail\_object)

That works just fine. However I have method chain hooking into instance  
method deliver!:

alias\_method\_chain :deliver!, :something\_crazy

so I need to send directly using deliver\_without\_something\_crazy!  
method. Easy, right? All that I need to do is call:  
ActionMailer::Base.new.deliver\_without\_something\_crazy!(my\_mail\_object)

Problem is that ActionMailer::Base.new returns nil for whatever reason.  
That doesn’t make much sense to me because this is the definition of  
deliver method:

ActionMailer::Base.deliver(mail)  
new.deliver!(mail)  
end

So, if I return/raise ‘new’ inside that function it actually returns  
ActionMailer::Base object instead of nil. As far as I can see those  
should be identical calls, returning the same result.

Can anybody shine some light on this?
