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
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
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.