Sha256: 9585ac101c7e7b3e1ee7f5a32fae0d655dea2ecf3b29fea311780d9254630c99

Contents?: true

Size: 1.89 KB

Versions: 15

Compression:

Stored size: 1.89 KB

Contents

# frozen_string_literal: true
#
# This whole class and associated specs is deprecated and will go away in the version 3 release of mail.
module Mail
  module CheckDeliveryParams #:nodoc:
    class << self

      extend Gem::Deprecate

      def check(mail)
        envelope = Mail::SmtpEnvelope.new(mail)
        [ envelope.from,
          envelope.to,
          envelope.message ]
      end
      deprecate :check, 'Mail::SmtpEnvelope.new created in commit c106bebea066782a72e4f24dd37b532d95773df7', 2023, 6

      def check_from(addr)
        mail = Mail.new(from: 'deprecated@example.com', to: 'deprecated@example.com')
        Mail::SmtpEnvelope.new(mail).send(:validate_addr, 'From', addr)
      end
      deprecate :check_from, :none, 2023, 6

      def check_to(addrs)
        mail = Mail.new(from: 'deprecated@example.com', to: 'deprecated@example.com')
        Array(addrs).map do |addr|
          Mail::SmtpEnvelope.new(mail).send(:validate_addr, 'To', addr)
        end
      end
      deprecate :check_to, :none, 2023, 6

      def check_addr(addr_name, addr)
        mail = Mail.new(from: 'deprecated@example.com', to: 'deprecated@example.com')
        Mail::SmtpEnvelope.new(mail).send(:validate_addr, addr_name, addr)
      end
      deprecate :check_addr, :none, 2023, 6

      def validate_smtp_addr(addr)
        if addr
          if addr.bytesize > 2048
            yield 'may not exceed 2kB'
          end

          if /[\r\n]/ =~ addr
            yield 'may not contain CR or LF line breaks'
          end
        end

        addr
      end
      deprecate :validate_smtp_addr, :none, 2023, 6

      def check_message(message)
        message = message.encoded if message.respond_to?(:encoded)

        if Utilities.blank?(message)
          raise ArgumentError, 'An encoded message is required to send an email'
        end

        message
      end
      deprecate :check_message, :none, 2023, 6
    end
  end
end

Version data entries

15 entries across 14 versions & 6 rubygems

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