Sha256: e5ef90a5e81b6d47d5bbeaf57ed74955d153d23bc1c5b95ad8500a3536a6a8d2

Contents?: true

Size: 1.61 KB

Versions: 1

Compression:

Stored size: 1.61 KB

Contents

######################################################################
#                        EMAIL NOTIFIER TASKS                        #
######################################################################
require 'mail'

Capistrano::Configuration.instance(:must_exist).load do |cap|
  after     'deploy',                 'notify:via_email'

  namespace :notify do
    desc <<-DESC
      [internal] Sends a notification via email once a deployment is complete.
    DESC
    task :via_email do
      Mail.defaults do
        delivery_method cap[:email_notifier_mail_method], cap[:email_notifier_mail_options]
      end

      if !cap[:email_notifier_client_recipients].empty?
        begin
          Mail.deliver do
                to cap[:email_notifier_client_recipients]
              from cap[:email_notifier_sender]
          subject cap[:email_notifier_subject]
              body cap[:email_notifier_client_body]
          end
        rescue
          puts "I'm sorry Dave, but I couldn't contact the mail server.  The client email notifications you requested have not been sent"
        end
      end

      if !cap[:email_notifier_internal_recipients].empty?
        begin
          Mail.deliver do
                to cap[:email_notifier_internal_recipients]
              from cap[:email_notifier_sender]
          subject cap[:email_notifier_subject]
              body cap[:email_notifier_internal_body]
          end
        rescue
          puts "I'm sorry Dave, but I couldn't contact the mail server.  The email notifications to the development team you requested have not been sent"
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chicken_soup-0.6.0 lib/chicken_soup/notifiers/email/email-tasks.rb