Displaying form body in email

Hi, total newb here.

I want to send an email via a form. I am at a stage where I can send an
email but am not sure how to display the email content that should come
from the form body. At the moment I have a subject and nothing else.
Here’s what I’ve got.

#contact_controller.rb
class ContactController < ApplicationController
def index
@result = params[:message]
end

def send_mail
#line below sends email
Notifier.deliver_signup_notification()
#flash notice and redirect after sending mail
flash[:notice] = ‘email sent to www.example.com.’
redirect_to “http://www.example.com
end
end

#notifier.rb:
class Notifier < ActionMailer::Base
def signup_notification()
recipients “[email protected]
from “[email protected]
subject “New inquiry”
body :message => @result
end
end

#index.rhtml:
<% form_tag( :action => :send_mail ) do %>
<%= text_area_tag :message, params[:message], :size => “25x10” %>
<%= submit_tag( “Send” ) %>
<% end %>

#signup_notification.rhtml:
The <%= @message %>

thanks for any help, I’ve been stuck on this one for awhile.

Tom E. wrote:

Hi, total newb here.

I want to send an email via a form. I am at a stage where I can send an
email but am not sure how to display the email content that should come
from the form body. At the moment I have a subject and nothing else.
Here’s what I’ve got.

#contact_controller.rb
class ContactController < ApplicationController
def index
@result = params[:message]
end

def send_mail
#line below sends email
Notifier.deliver_signup_notification()
#flash notice and redirect after sending mail
flash[:notice] = ‘email sent to www.example.com.’
redirect_to “http://www.example.com
end
end

#notifier.rb:
class Notifier < ActionMailer::Base
def signup_notification()
recipients “[email protected]
from “[email protected]
subject “New inquiry”
body :message => @result
end
end

#index.rhtml:
<% form_tag( :action => :send_mail ) do %>
<%= text_area_tag :message, params[:message], :size => “25x10” %>
<%= submit_tag( “Send” ) %>
<% end %>

#signup_notification.rhtml:
The <%= @message %>

thanks for any help, I’ve been stuck on this one for awhile.

D’oh, changed things about a touch in controller.rb and notifier.rb and
it now works.

class ContactController < ApplicationController
def send_mail
result = params[:message]
#line below sends email
Notifier.deliver_signup_notification(result)
#flash notice and redirect after sending mail
flash[:notice] = ‘email sent to www.example.com.’
redirect_to “http://www.example.com
end
end

class Notifier < ActionMailer::Base
def signup_notification(result)
recipients “[email protected]
from “[email protected]
subject “New inquiry”
body :message => result
end
end