Skip to content

Instantly share code, notes, and snippets.

@syshen
Created January 5, 2012 02:43
Show Gist options
  • Save syshen/1563461 to your computer and use it in GitHub Desktop.
Save syshen/1563461 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'action_mailer'
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:enable_starttls_auto => true,
:tls => true,
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:authentication => "plain",
:user_name => "[email protected]",
:password => "yourpassword"
}
class Notifier < ActionMailer::Base
default :from => "[email protected]"
def deploy_notification(cap_vars)
now = Time.now
msg = "<h2>Deploy on #{cap_vars.target}</h2><p><b>Date:</b> #{now.strftime("%m/%d/%Y")} at #{now.strftime("%I:%M %p")}</p><p><b>Current revision:</b> #{cap_vars.current_release}.</p>\n<p><b>Change log:</b></p>\n-----------------------------------------------------------------------<br\><p>#{cap_vars.history}</p><small>(this email is sent by deployment program, don't reply!)</small>"
mail(:to => cap_vars.notify_emails,
:subject => "#{cap_vars.application} was deployed to #{cap_vars.target} on #{now.strftime("%m/%d/%Y")}") do |format|
format.text { render :text => msg}
format.html { render :text => "<p>" + msg + "<\p>"}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment