Sha256: 608f6d648be13ab0ece93e3f30693fba77db030e96b5d6827ee4c57b254073b3

Contents?: true

Size: 632 Bytes

Versions: 1

Compression:

Stored size: 632 Bytes

Contents

require "mail"

module DailyWeeklyMonthly
  class Notifier
    def initialize smtp_server, smtp_port
      @smtp_server = smtp_server
      @smtp_port = smtp_port
    end

    # rubocop: disable Metrics/MethodLength
    def call exception, deliver_to
      mail = Mail.new {
        from "backups@localhost"
        to deliver_to
        subject "Backup failed"
        body <<EOF
Backup failure

#{exception.message}

#{exception.backtrace.join("\n")}
EOF
      }
      mail.delivery_method :smtp, address: @smtp_server, port: @smtp_port if @smtp_server && @smtp_port
      mail.deliver
    end
    # rubocop: enable all
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
daily_weekly_monthly-0.0.3 lib/daily_weekly_monthly/notifier.rb