# Calling ActionMailer model from script/console

**URL:** <https://www.ruby-forum.com/t/calling-actionmailer-model-from-script-console/163307>\
**Category:** Rails\
**Created:** [March 19, 2009, 5:11am UTC](https://www.ruby-forum.com/t/calling-actionmailer-model-from-script-console/163307 "2009-03-19T05:11:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![indigoi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/b3f665/32.png) [@indigoi](https://www.ruby-forum.com/u/indigoi)\
**Post date:** [March 19, 2009, 5:11am UTC](https://www.ruby-forum.com/t/calling-actionmailer-model-from-script-console/163307/1 "2009-03-19T05:11:31Z")

</div>

I am writing an app that receives emails and forwards them to different  
locations based on certain criteria. I can recieve emails, and i can  
send them, i’m just having a problem linking the two together.

The mailer model i am using is entitled My\_Mailer and under that model i  
have defined a receive method, and a welcome method. The recieve gets  
the email, and the welcome sends another email. Right now i have  
something like this

class MyMailer \< ActionMailer::Base

def receive(email)  
# parse and do ruby magic  
MyMailer.deliver\_welcome(user\_name, email\_address )  
end

def welcome(name, email)  
# sends a welcome message  
end  
end

Why when i call MyMailer.deliver\_welcome(user\_name, email\_address ) from  
my script/console i can send an email just fine but when i call it  
within the recieve method, it doesn’t work. Do you have any clue why a  
line of code would work from script/console but not in a model?

Also if i try to debug or call “puts ‘something’” within the MyMailer  
model nothing shows up in the console output.
