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