I've been working on a contact form, however, most of the examples I see
posted are outdated and I'm just having some trouble getting this to
work. Here's what I've done so far:
At the bottom of my environment.rb file I've placed:
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "mail.ncaastatpages.com",
:port => 25,
:domain => "ncaastatpages.com"
}
==========================================
In mail.yml within config I've placed the following:
development:
:address: mail.ncaastatpages.com
:port: 25
:authentication: plain
:user_name: [email protected]
:password: mypassword
==========================================
I created a mailer model which contains the method for notifications
def notifications(sent_at = Time.now)
subject params[:subject]
recipients '[email protected]'
from params[:address]
sent_on sent_at
body :greeting => params[:body], :sender_name => params[:name]
end
==========================================
I created the contact controller which contains:
class ContactController < ApplicationController
def index
# render index.html.erb
end
def send_mail
Mailer.deliver_notifications(params[:email])
flash[:notice] = "Email was succesfully sent."
redirect_to :action => "index"
end
end
===========================================
I have the form in my contact view for index.html.erb
<td>
<% form_tag :action => "send_mail" do %>
<tr><td>
<%= label :email, :name, "Name" %><br />
<%= text_field :email, :name %>
</td></tr>
<tr><td>
<%= label :email, :address, "Your Email
Address" %><br />
<%= text_field :email, :address %>
</td></tr>
<tr><td>
<%= label :email, :subject, "Subject" %><br />
<%= text_field :email, :subject %>
</td></tr>
<tr><td>
<%= label :email, :body, "Your Message" %><br
/>
<%= text_area :email, :body, :rows => 8, :cols
=> 50 %>
</td></tr>
<tr><td>
<%= submit_tag "Submit" %>
</td></tr>
<% end %>
</td>
==================================================
I added the following map route:
map.contact '/contact/send_mail', :controller => 'contact', :action =>
'send_mail'
==================================================
I go to the contacts page and see the form fine.
When I enter the information and submit I receive the following error:
undefined local variable or method `params' for #<Mailer:0x3c9d6f8>
It shows contact_controller.rb:7:in `send_mail'
which contains..
Mailer.deliver_notifications(params[:email])
==================================================
I know I'm probably doing a few things wrong but mailing seems to be a
very difficult process for me to learn. Any help would be appreciated.
Thanks.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---