I've tried to delay this moment as long as possible but here it is. I've almost made it with the mailer. Its all set up but there is a problem. I'm also storing the contact form info in the Db for reference and I've got the params to show up in my error messages so they are there. I cant seem to be able to pass request params into the new function I defined in the mailer as it asks for methods of Contact (the model) and doesn't interpret as values in the deliver method. Any help?
On Sep 1, 10:47 pm, Joachim Bartosik <[email protected]> wrote: > 01.09.2010 22:10, Scorpio wrote: > > Hi it's me again > > > I've been trying to make a contact form with hobo at work and its > > kinda going along but then I realized I have no idea how to mail that > > to an email address. > > You should use ActionMailer to send emails. I'l give you example from my > app. > > I added following methods to UserMailer class (in > app/models/user_mailer.rb): > > def common(user, subject) > �...@recipients = user.email_address > @from = "no-re...@#{ ActionMailer::Base.default_url_options[:host] }" > @sent_on = Time.now > @headers = {} > @subject = subject > end > > def new_answer(user, answer) > common(user, "New answer") > @body = { :question_title=> question_title(answer), :recruit_name => > answer.owner.name, :id => answer.id} > end > > And created app/views/user_mailer/new_answer.erb file with following > content: > > Recruit you are mentoring - <%= @recruit_name %> answered question > "<%= @question_title %>". > > <%= answer_url(@id) %> > > When I want to send new answer notification I call > > UserMailer.deliver_new_answer(user_to_notify, answer) > > Hope that helps, > Joachim > > signature.asc > < 1KViewDownload -- You received this message because you are subscribed to the Google Groups "Hobo Users" 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/hobousers?hl=en.
