Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class HomeController < ApplicationController
def index
end
def send_mail
name = params[:name]
email = params[:email]
body = params[:body]
UserMailer.contact_mail(name, email, body).deliver
end
end
view:
<!DOCTYPE html>
<html>
<head>
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<p>You have received the following email from <%= "#{ @name } (#{ @email }):" %></p>
<p><%= @body %></p>
</body>
</html>
ActionMailer:
class UserMailer < ActionMailer::Base
default to: "bradfordli@gmail.com"
def contact_mail(name, email, body)
@name = name
@email = email
@body = body
mail(from: email, subject: "Contact Request")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment