# ActionMailer outside of Rails to send HTML mails

**URL:** <https://www.ruby-forum.com/t/actionmailer-outside-of-rails-to-send-html-mails/166273>\
**Category:** Ruby\
**Created:** [April 23, 2009, 11:47am UTC](https://www.ruby-forum.com/t/actionmailer-outside-of-rails-to-send-html-mails/166273 "2009-04-23T11:47:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ptriller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b9e5f3/32.png) [@ptriller](https://www.ruby-forum.com/u/ptriller)\
**Post date:** [April 23, 2009, 11:47am UTC](https://www.ruby-forum.com/t/actionmailer-outside-of-rails-to-send-html-mails/166273/1 "2009-04-23T11:47:04Z")

</div>

I am trying to build a small newsletter application.  
I am however failing somehomw…

I am trying this simple sample code:

```
require 'net/http'
require 'rubygems'
require 'action_mailer'

recivers = []
recivers = IO.readlines("mial.txt")

h = Net::HTTP.new('http://...', 80)
resp, @data = h.get('...', nil)

ActionMailer::Base.default_content_type = "text/html"
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
  :address => "...",
  :port => 25,
  :domain => '...'
}

class Emailer < ActionMailer::Base
  def test_email(subject, user_email)
    subject subject
    from "..."
    recipients user_email
    body :body => @data
  end
end

recivers.each do |reciver|
        Emailer.deliver_test_email("Testing", reciver)
end
```

And when I run this I get NoMethodError: undefined method  
â€˜find\_templateâ€™ for []:Array

I suppose I have to have a template somewhere but I can’t figure out  
where to put it?

All help welcome

---

<div class="post-metadata">

**Author:** ![ptriller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b9e5f3/32.png) [@ptriller](https://www.ruby-forum.com/u/ptriller)\
**Post date:** [April 23, 2009, 1:01pm UTC](https://www.ruby-forum.com/t/actionmailer-outside-of-rails-to-send-html-mails/166273/2 "2009-04-23T13:01:04Z")

</div>

> recivers = []  
> :domain =\> ‘…’
> 
> All help welcome

Use ActionMailer::Base.template\_root = … to set the path your email  
templates reside in. In your example, ActionMailer will search for a  
template named ‘test\_email’ (plus extension) unless you provide a  
different  
one to render\_message method.

Hope it helps  
Cheers

Alex
