Sending Email


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.

A quick google is all you need:

Or buy one of the Rails books.


Jonathan V. wrote:

A quick google is all you need:

Or buy one of the Rails books.


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.

Some posted exactly what I needed:

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’)

Your mailer could be…

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

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).