Skip to content

Instantly share code, notes, and snippets.

@liondancer
Created November 17, 2014 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liondancer/8653875f3049272b7091 to your computer and use it in GitHub Desktop.
Save liondancer/8653875f3049272b7091 to your computer and use it in GitHub Desktop.
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