Sha256: e977696f901f56042136847c3c578ffbcf3ca5c95693a8211e103904978655d2

Contents?: true

Size: 1.14 KB

Versions: 16

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true
require 'mail/smtp_envelope'

module Mail
  # The TestMailer is a bare bones mailer that does nothing.  It is useful
  # when you are testing.
  # 
  # It also provides a template of the minimum methods you require to implement
  # if you want to make a custom mailer for Mail
  class TestMailer
    # Provides a store of all the emails sent with the TestMailer so you can check them.
    def self.deliveries
      @@deliveries ||= []
    end

    # Allows you to over write the default deliveries store from an array to some
    # other object.  If you just want to clear the store, 
    # call TestMailer.deliveries.clear.
    # 
    # If you place another object here, please make sure it responds to:
    # 
    # * << (message)
    # * clear
    # * length
    # * size
    # * and other common Array methods
    def self.deliveries=(val)
      @@deliveries = val
    end

    attr_accessor :settings

    def initialize(values)
      @settings = values.dup
    end

    def deliver!(mail)
      # Create the envelope to validate it
      Mail::SmtpEnvelope.new(mail)

      Mail::TestMailer.deliveries << mail
    end
  end
end

Version data entries

16 entries across 15 versions & 6 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/mail-2.8.1/lib/mail/network/delivery_methods/test_mailer.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/network/delivery_methods/test_mailer.rb
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/mail-2.8.1/lib/mail/network/delivery_methods/test_mailer.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/mail-2.8.1/lib/mail/network/delivery_methods/test_mailer.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/network/delivery_methods/test_mailer.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/network/delivery_methods/test_mailer.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/network/delivery_methods/test_mailer.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/network/delivery_methods/test_mailer.rb
mail-2.8.1 lib/mail/network/delivery_methods/test_mailer.rb
mail-2.8.1.rc2 lib/mail/network/delivery_methods/test_mailer.rb
mail-2.8.0.1 lib/mail/network/delivery_methods/test_mailer.rb
mail-2.8.0.1.rc1 lib/mail/network/delivery_methods/test_mailer.rb
mail-2.8.0 lib/mail/network/delivery_methods/test_mailer.rb
mail-2.8.0.rc3 lib/mail/network/delivery_methods/test_mailer.rb
mail-2.8.0.rc2 lib/mail/network/delivery_methods/test_mailer.rb
mail-2.8.0.rc1 lib/mail/network/delivery_methods/test_mailer.rb