ActionMailer outside of Rails?

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

ActionMailer has a configuration option called template_root.

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

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 :slight_smile:

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 (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’.