# Sending Email

**URL:** <https://www.ruby-forum.com/t/sending-email/96074>\
**Category:** Rails\
**Created:** [June 25, 2006, 3:42am UTC](https://www.ruby-forum.com/t/sending-email/96074 "2006-06-25T03:42:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidstokar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/4da419/32.png) [@davidstokar](https://www.ruby-forum.com/u/davidstokar)\
**Post date:** [June 25, 2006, 3:42am UTC](https://www.ruby-forum.com/t/sending-email/96074/1 "2006-06-25T03:42:21Z")

</div>

Hi,

I want users of my application to send emails using a feedback form to  
other users of my application. I don’t want to publish their email  
addresses, but I have them in my application.

I have an ActionMailer model class called contact.rb. My problem is that  
I don’t know how to set up the Contact form so that it can send  
information directly to the controller that then emails the information,  
by sending it to the ActionMailer. I have found some examples, but they  
seem complex and all the examples sends the email using a view.

Can someone please give an example?

Your help will be appreciated.

---

<div class="post-metadata">

**Author:** ![davidstokar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/4da419/32.png) [@davidstokar](https://www.ruby-forum.com/u/davidstokar)\
**Post date:** [June 25, 2006, 4:31am UTC](https://www.ruby-forum.com/t/sending-email/96074/2 "2006-06-25T04:31:44Z")

</div>

A quick google is all you need:

[http://wiki.rubyonrails.org/rails/pages/ActionMailer](http://wiki.rubyonrails.org/rails/pages/ActionMailer)

> **[ActionMailer::Base](https://api.rubyonrails.org/classes/ActionMailer/Base.html)**
>
> Action Mailer allows you to send email from your application using a mailer model and views. Mailer Models To use Action Mailer, you need to create a mailer model.

Or buy one of the Rails books.

-Jonathan.

---

<div class="post-metadata">

**Author:** ![davidstokar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/4da419/32.png) [@davidstokar](https://www.ruby-forum.com/u/davidstokar)\
**Post date:** [June 26, 2006, 6:05am UTC](https://www.ruby-forum.com/t/sending-email/96074/3 "2006-06-26T06:05:56Z")

</div>

Jonathan V. wrote:

> A quick google is all you need:
> 
> [http://wiki.rubyonrails.org/rails/pages/ActionMailer](http://wiki.rubyonrails.org/rails/pages/ActionMailer)  
> [ActionMailer::Base](http://api.rubyonrails.org/classes/ActionMailer/Base.html)
> 
> Or buy one of the Rails books.
> 
> -Jonathan.

I have looked at both those sites, before I posted to the forum. The  
problem I am having is passing the information from the email feedback  
form to the controller and then sending the information in an email. At  
the moment I can’t seem to be able to pass the info to the controller.

---

<div class="post-metadata">

**Author:** ![davidstokar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/4da419/32.png) [@davidstokar](https://www.ruby-forum.com/u/davidstokar)\
**Post date:** [June 26, 2006, 9:24pm UTC](https://www.ruby-forum.com/t/sending-email/96074/4 "2006-06-26T21:24:35Z")

</div>

Some posted exactly what I needed:  
[http://www.ruby-forum.com/topic/70710#96698](http://www.ruby-forum.com/topic/70710#96698)  
[http://www.bphogan.com/learn/pdf/tableless\_contact\_form.pdf](http://www.bphogan.com/learn/pdf/tableless_contact_form.pdf)

---

<div class="post-metadata">

**Author:** ![davidstokar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/4da419/32.png) [@davidstokar](https://www.ruby-forum.com/u/davidstokar)\
**Post date:** [June 26, 2006, 6:24am UTC](https://www.ruby-forum.com/t/sending-email/96074/5 "2006-06-26T06:24:49Z")

</div>

The data from the form gets passed to the action in params. As well as  
the data from params, you can pass anything to the mailer.

class MyController  
def my\_action  
MyMailer.deliver\_message(params[:text], :subject =\> ‘My email’)  
end  
end

Your mailer could be…

class MyMailer \< ActionMailer::Base  
def message(text, options = {})  
# set subject, recipients, etc… see one of the examples  
end  
end

You say you can’t pass data from the form on the page to the  
controller? That problem is unrelated to sending the email. Look for  
some examples of submitting forms (any Rails tutorial).

-Jonathan.
