ve been breaking my head to send an email from the feedback form in my
website. Ive followed a few tutorials on rails forum and else where but
i cant get it to work yet. So i want to know where i have been going
wrong.
Here is my code in the view which gets the values for the feedback
1. <form name="feedback" method="POST"
action="/mailer/feedback">
2. <select name= "feedback[content]">
3. <option
value="Excellent">Excellent</option>
4. <option value="Very Good">Very
Good</option>
5. <option vlaue="Fair">Fair</option>
6. <option value="Poor">Poor</option>
7. <option value="Very Poor">Very
Poor</option>
8. </select>
9. <select name= "feedback[design]">
10. <option
value="Excellent">Excellent</option>
11. <option value="VeryGood">Very
Good</option>
12. <option vlaue="Fair">Fair</option>
13. <option value="Poor">Poor</option>
14. <option value="VeryPoor">Very
Poor</option>
15. </select>
here is the action feedback in the controller mailer
1. def feedback
2. if request.post?
3. begin
4. Notifier.deliver_feedback(params[:feedback])
5. flash[:message] = "Feedback sent"
6. redirect_to :controller => '/site', :action =>
'home'
7. rescue
8. flash[:message] = "Error Sending mail"
9. redirect_to :controller => '/site', :action =>
'home'
10. end
11. end
12. end
i also created a mailer named Notifier and the contents of the notifier
is as follows
1. def feedback(feedback)
2.
3. @recipients = '[email protected]'
4. @from = feedback[:email]
5. @subject = 'Feedback for website'
6. @body['content'] = feedback[:content]
7. @body['design'] = feedback[:design]
8. end
i created a rhtml file named feedback in views/notifier
the content to be sent in the email
1. Dear Administrator,
2.
3. You have got a feedback for the website
4.
5. Scores
6.
7. Content : <%= @content %>
8. Design : <%= @design %>
9. Usability : <%= @usability %>
10.
11. Comments : <%= @comments %>
i added these in environment.rb file as follows
i actually removed the word :action_mailer from config.frameworks as
described in a wiki tutorial
1. # Skip frameworks you're not going to use (only works if
using vendor/rails)
2. # config.frameworks -= [ :action_web_service]
3.
4. # Include your app's configuration here:
5. ActionMailer::Base.server_settings = {
6. :address => "abc",
7. :port => 25,
8. :domain => 'abc',
9. :user_name => "[email protected]",
10. :password => "mypass",
11. :authentication => :login
12. }
I want to know where i have been going wrong or anything i missed thats
stopping from sending email. Its been 2 days ive been working on this
without any luck. Any help is very much appreciated