0

In one of my rails application I have to send a email. I just configured my app like follows.

I am using Rails v2.0.

environment.rb:

RAILS_GEM_VERSION = '2.0.2' unless defined? RAILS_GEM_VERSION # Bootstrap the Rails environment, frameworks, and default configuration require File.join(File.dirname(__FILE__), 'boot') Rails::Initializer.run do |config| config.action_controller.session = { :session_key => '_mailtest_session', :secret => 'key_here' } ActionMailer::Base.delivery_method = :smtp ActionMailer::Base.smtp_settings = { :address => "smtp.gmail.com", :port => 25, :domain => "gmail.com", :authentication => :login, :user_name => "[email protected]", :password => "password" } ActionMailer::Base.default_content_type = "text/html" end 

models/notifier.rb:

class Notifier < ActionMailer::Base def contact(recipient, subject, message, sent_at = Time.now) @subject = subject @recipients = recipient @from = '[email protected]' @sent_on = sent_at @body["title"] = 'Signup Info' @body["email"] = '[email protected]' @body["message"] = message @headers = {} return true end end 

controller/administrator

class AdministratorController < ApplicationController def index recipient = "[email protected]" subject = "Subject" message = "message" Notifier.deliver_contact(recipient, subject, message) end end 

When I tried to call index method I m getting this error:

Couldn't find template file for notifier/contact in ["D:/Rails/rails_apps/mailtest/app/views"] 

Please help ...

2
  • 1
    What files do you have in that view directory? Commented Dec 28, 2011 at 6:52
  • For testing I just created a blank contact.html.erb file in my views folder Commented Dec 28, 2011 at 8:43

1 Answer 1

1

Create a directory named notifier under app/views, and place contact.html.erb there. One of Rails' conventions is that it expects the view directory to be named after the mailer/controller class.

Sign up to request clarification or add additional context in comments.

2 Comments

Hi rkb .. I just created a blank file named contact.html.erb in my app/views .. But showing the same error ...
You want to create the file in app/views/notifier/.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.