Using ActionMailer with template files retrieved from sql da

I’m trying to set up a system which allows users to create and modify
emails to send out to clients. I’ve got ActionMailer set up to send
from a template file stored on the file system, but I’d like to be
able to move this into the database. Does anyone know how to get
ActionMailer to read the contents of the email from a database table
rather than the on-disk template file? Thanks,

Mike

Hi Mike

In your class that extends ActionMailer::Base, assuming that you have a
User class and the contents of the email you want to send is in the
email_contents field, use code like this:

@body = initialize_template_class(:user => user).render(:inline =>
user.email_contents)

Cheers,

Cloves Carneiro Jr
http://re.visioni.st

Mike G. wrote:

I’m trying to set up a system which allows users to create and modify
emails to send out to clients. I’ve got ActionMailer set up to send
from a template file stored on the file system, but I’d like to be
able to move this into the database. Does anyone know how to get
ActionMailer to read the contents of the email from a database table
rather than the on-disk template file? Thanks,

Mike

On 2-jun-2006, at 0:44, Cloves Carneiro Jr wrote:

Hi Mike

In your class that extends ActionMailer::Base, assuming that you
have a
User class and the contents of the email you want to send is in the
email_contents field, use code like this:

@body = initialize_template_class(:user => user).render(:inline =>
user.email_contents)

Please please wiki that.

Note to the one who asked - make sure to use Liquid or Raduis or such
because you can’t allow your users to write ERB (if you care about
security)


Julian ‘Julik’ Tarkhanov
please send all personal mail to
me at julik.nl