# ActionMailer outside of Rails?

**URL:** <https://www.ruby-forum.com/t/actionmailer-outside-of-rails/104028>\
**Category:** Rails\
**Created:** [May 13, 2007, 4:22am UTC](https://www.ruby-forum.com/t/actionmailer-outside-of-rails/104028 "2007-05-13T04:22:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jasongarber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/977dab/32.png) [@jasongarber](https://www.ruby-forum.com/u/jasongarber)\
**Post date:** [May 13, 2007, 4:22am UTC](https://www.ruby-forum.com/t/actionmailer-outside-of-rails/104028/1 "2007-05-13T04:22:27Z")

</div>

Has anyone used ActionMailer outside of rails? I have a requirement for  
work that will not allow me to do this from within a rails app. I have  
successfully sent an email in the following manner:

MyMailer.deliver\_clever\_email(someArg,‘testing!’)

where the second argument is the body of the email, but when I try to  
call just:

MyMailer.deliver\_clever\_email(someAr)

and use a template, it complains that it doesn’t know where to find the  
rhtml template. How do I tell it where to look? Any help would be  
greatly appreciated!

-jay

---

<div class="post-metadata">

**Author:** ![jasongarber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/977dab/32.png) [@jasongarber](https://www.ruby-forum.com/u/jasongarber)\
**Post date:** [May 13, 2007, 4:35am UTC](https://www.ruby-forum.com/t/actionmailer-outside-of-rails/104028/2 "2007-05-13T04:35:50Z")

</div>

ActionMailer has a configuration option called template\_root.

[http://api.rubyonrails.org/classes/ActionMailer/Base.html](http://api.rubyonrails.org/classes/ActionMailer/Base.html) (see  
Configuration)

This allows you to set the search path for templates. AFAIK, this is  
really just the root, so it will look for  
‘#{TEMPLATE\_ROOT}/my\_mailer/clever\_email.rhtml’.

Jason Guiditta wrote:

> Has anyone used ActionMailer outside of rails? I have a requirement for  
> work that will not allow me to do this from within a rails app. I have  
> successfully sent an email in the following manner:
> 
> MyMailer.deliver\_clever\_email(someArg,‘testing!’)
> 
> where the second argument is the body of the email, but when I try to  
> call just:
> 
> MyMailer.deliver\_clever\_email(someAr)
> 
> and use a template, it complains that it doesn’t know where to find the  
> rhtml template. How do I tell it where to look? Any help would be  
> greatly appreciated!
> 
> -jay

---

<div class="post-metadata">

**Author:** ![jasongarber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/977dab/32.png) [@jasongarber](https://www.ruby-forum.com/u/jasongarber)\
**Post date:** [May 14, 2007, 1:17am UTC](https://www.ruby-forum.com/t/actionmailer-outside-of-rails/104028/3 "2007-05-14T01:17:37Z")

</div>

Many thanks, Florian, that was exactly what I missed, works like a charm  
now! All I had to to was point it to the root view directory and it  
figured the rest out on its own 🙂

ActionMailer::Base.template\_root = “views/”

-jay

Florian G. wrote:

> ActionMailer has a configuration option called template\_root.
> 
> [http://api.rubyonrails.org/classes/ActionMailer/Base.html](http://api.rubyonrails.org/classes/ActionMailer/Base.html) (see  
> Configuration)
> 
> This allows you to set the search path for templates. AFAIK, this is  
> really just the root, so it will look for  
> ‘#{TEMPLATE\_ROOT}/my\_mailer/clever\_email.rhtml’.
