Skip to content

Instantly share code, notes, and snippets.

@kryali
Created December 27, 2010 18:09
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 kryali/756370 to your computer and use it in GitHub Desktop.
Save kryali/756370 to your computer and use it in GitHub Desktop.
# app/mailers/user_mailer.rb
class UserMailer < ActionMailer::Base
default :from => "noreply@coursesillinois.com"
def welcome_email(user)
@user = user
@url = "http://coursesillinois.com/login"
mail(:to => "myemail@gmail.com", :subject => "Welcome to My Awesome Site")
end
end
# app/views/user_mailer/welcome_email.html.erb
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
</head>
<body>
<h1>A new user has registered</h1>
<p>Let's see if you can get this email first though</p>
</body>
</html>
# where I call the welcome_email
def create
@user = User.create(params[:user])
@user.save
UserMailer.welcome_email(@user).deliver
redirect_to(Post)
flash[:notice] = @user.errors
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment