i had generated the controller as:
class EmailerController < ApplicationController
def sendmail
email = @params[“email”]
recipient = email[recipient]
subject = email[subject]
message = email[message]
Emailer.deliver_contact(recipient, subject, message)
return if request.xhr?
render :text => ‘Sucessfully sent a mail…’
end
def index
render :file => ‘app\views\emailer\index.rhtml’
end
end
and model as:
class Emailer < ActionMailer::Base
def contact(recipient, subject, message, sent_at = Time.now)
@subject = subject
@recipients = recipient
@from = ‘[email protected]’
@sent_on = sent_at
@body[“title”] = ‘This is title’
@body[“email”] = ‘[email protected]’
@body[“message”] = message
@headers = {}
end
end
in environment.rb i had given like this:
ActionMailer::Base.delivery_method =:sendmail
ActionMailer::Base.server_settings = {
:address => “localhost”,
:port => 25,
:domain => “gmail.com”,
:authentication => :login,
:user_name => “username”,
:password => "password
}
and in app\views\emailer\contact.rhtml:
Hi!
You are having one email message from <%= @email %> with a tilte
<%= @title %>
and following is the message:
<%= @message %>
Thanks
and in app\views\emailer\index.rhtml:
Send Email
<%= start_form_tag :action => 'sendmail' %>Subject: <%= text_field 'email', 'subject' %>
Recipient: <%= text_field 'email', 'recipient' %>
Message
<%= text_area 'email', 'message' %>
but still i cannot able to send the mails… what are the changes
required please kindly send me code…