Sha256: 468cd2dfbeafe7ddf0eb69884e8d81d8d114fd5a53b5a06689aedd7cbfce7037

Contents?: true

Size: 1.05 KB

Versions: 16

Compression:

Stored size: 1.05 KB

Contents

module RequestLogAnalyzer

  class Mailer
    
    attr_accessor :data, :to, :host
    
    # Initialize a mailer
    # <tt>to</tt> to address
    # <tt>host</tt> the mailer host
    # <tt>options</tt> Specific style options
    def initialize(to, host = 'localhost', options = {})
      require 'net/smtp' 
      @to      = to
      @host    = host
      @options = options
      @data    = []
    end
    
    def mail
      from        = @options[:from]        || 'contact@railsdoctors.com'
      from_alias  = @options[:from_alias]  || 'Request-log-analyzer reporter'
      to_alias    = @options[:to_alias]    || to
      subject     = @options[:subjeect]    || "Request log analyzer report - generated on #{Time.now.to_s}"
    msg = <<END_OF_MESSAGE
From: #{from_alias} <#{from}>
To: #{to_alias} <#{@to}>
Subject: #{subject}

#{@data.to_s}
END_OF_MESSAGE
      
      Net::SMTP.start(@host) do |smtp|
        smtp.send_message msg, from, to
      end
    end
  
    def << string
      data << string
    end
    
    def puts string
      data << string
    end

  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
wvanbergen-request-log-analyzer-1.3.0 lib/request_log_analyzer/mailer.rb
wvanbergen-request-log-analyzer-1.3.1 lib/request_log_analyzer/mailer.rb
wvanbergen-request-log-analyzer-1.3.2 lib/request_log_analyzer/mailer.rb
wvanbergen-request-log-analyzer-1.3.3 lib/request_log_analyzer/mailer.rb
wvanbergen-request-log-analyzer-1.3.4 lib/request_log_analyzer/mailer.rb
wvanbergen-request-log-analyzer-1.3.5 lib/request_log_analyzer/mailer.rb
wvanbergen-request-log-analyzer-1.3.6 lib/request_log_analyzer/mailer.rb
wvanbergen-request-log-analyzer-1.3.7 lib/request_log_analyzer/mailer.rb
request-log-analyzer-1.3.7 lib/request_log_analyzer/mailer.rb
request-log-analyzer-1.3.6 lib/request_log_analyzer/mailer.rb
request-log-analyzer-1.3.5 lib/request_log_analyzer/mailer.rb
request-log-analyzer-1.3.4 lib/request_log_analyzer/mailer.rb
request-log-analyzer-1.3.3 lib/request_log_analyzer/mailer.rb
request-log-analyzer-1.3.2 lib/request_log_analyzer/mailer.rb
request-log-analyzer-1.3.1 lib/request_log_analyzer/mailer.rb
request-log-analyzer-1.3.0 lib/request_log_analyzer/mailer.rb