# Displaying form body in email

**URL:** <https://www.ruby-forum.com/t/displaying-form-body-in-email/109729>\
**Category:** Rails\
**Created:** [July 18, 2007, 1:00pm UTC](https://www.ruby-forum.com/t/displaying-form-body-in-email/109729 "2007-07-18T13:00:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomzoo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a88e4f/32.png) [@tomzoo](https://www.ruby-forum.com/u/tomzoo)\
**Post date:** [July 18, 2007, 1:00pm UTC](https://www.ruby-forum.com/t/displaying-form-body-in-email/109729/1 "2007-07-18T13:00:01Z")

</div>

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](http://www.example.com).’  
redirect\_to “[http://www.example.com](http://www.example.com)”  
end  
end

#notifier.rb:  
class Notifier \< ActionMailer::Base  
def signup\_notification()  
recipients “removed\_email\_address@domain.invalid”  
from “removed\_email\_address@domain.invalid”  
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.

---

<div class="post-metadata">

**Author:** ![tomzoo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a88e4f/32.png) [@tomzoo](https://www.ruby-forum.com/u/tomzoo)\
**Post date:** [July 18, 2007, 2:10pm UTC](https://www.ruby-forum.com/t/displaying-form-body-in-email/109729/2 "2007-07-18T14:10:24Z")

</div>

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](http://www.example.com).’  
> redirect\_to “[http://www.example.com](http://www.example.com)”  
> end  
> end
> 
> #notifier.rb:  
> class Notifier \< ActionMailer::Base  
> def signup\_notification()  
> recipients “removed\_email\_address@domain.invalid”  
> from “removed\_email\_address@domain.invalid”  
> 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](http://www.example.com).’  
redirect\_to “[http://www.example.com](http://www.example.com)”  
end  
end

class Notifier \< ActionMailer::Base  
def signup\_notification(result)  
recipients “removed\_email\_address@domain.invalid”  
from “removed\_email\_address@domain.invalid”  
subject “New inquiry”  
body :message =\> result  
end  
end
