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
Description: OpenPGP digital signature
