# Why won't my ActionMailer work inside the controller?

**URL:** <https://www.ruby-forum.com/t/why-wont-my-actionmailer-work-inside-the-controller/169063>\
**Category:** Rails\
**Created:** [May 28, 2009, 10:08pm UTC](https://www.ruby-forum.com/t/why-wont-my-actionmailer-work-inside-the-controller/169063 "2009-05-28T22:08:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmorin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f0a364/32.png) [@dmorin](https://www.ruby-forum.com/u/dmorin)\
**Post date:** [May 28, 2009, 10:08pm UTC](https://www.ruby-forum.com/t/why-wont-my-actionmailer-work-inside-the-controller/169063/1 "2009-05-28T22:08:21Z")

</div>

I’ve got a basic mailer setup and am simply trying to get a Hello  
message through. If I go into script/console and execute

Emailer.deliver\_message(“removed\_email\_address@domain.invalid”,“My subject”, “My  
message”)

it works fine.

However, if I fire up a controller with a test method that invokes the  
same thing

def test  
Emailer.deliver\_message(“removed\_email\_address@domain.invalid”,“My subject”, “My  
message”)  
end

I never see the message. Something obvious I’m missing in the context  
of running it in the controller?

---

<div class="post-metadata">

**Author:** ![dmorin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f0a364/32.png) [@dmorin](https://www.ruby-forum.com/u/dmorin)\
**Post date:** [May 30, 2009, 12:14pm UTC](https://www.ruby-forum.com/t/why-wont-my-actionmailer-work-inside-the-controller/169063/2 "2009-05-30T12:14:50Z")

</div>

On May 28, 9:08 pm, Duane M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> def test  
> Emailer.deliver\_message(“removed\_email\_address@domain.invalid”,“My subject”, “My  
> message”)  
> end
> 
> I never see the message. Something obvious I’m missing in the context  
> of running it in the controller?

Shouldn’t be. Stupid question : are you sure the code is actually  
getting run? (the action name may be relevant here) Is the instance of  
rails serving your web request running with a different RAILS\_ENV (ie  
potentially different action mailer settings) ?

Fred
