Tom Eustace 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 "me-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org"
>     from       "info-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org"
>     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 "me-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org"
    from       "info-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org"
    subject    "New inquiry"
    body       :message => result
  end
end
-- 
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---