Sha256: 17f113438f1433af9d91ffa48062abf0f4541a133756a4ad67342dfccf1b2686

Contents?: true

Size: 474 Bytes

Versions: 3

Compression:

Stored size: 474 Bytes

Contents

module Mailbin
  class DeliveryMethod
    attr_accessor :settings

    def initialize(options = {})
      self.settings = options
    end

    def deliver!(mail)
      mail.message_id = SecureRandom.uuid

      FileUtils.mkdir_p(settings[:location])
      File.open(location_for(mail), "w") do |file|
        file.write(mail.encoded)
      end
    end

    private

    def location_for(mail)
      File.join(settings[:location], mail.message_id + ".eml")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mailbin-1.0.0 lib/mailbin/delivery_method.rb
mailbin-0.1.1 lib/mailbin/delivery_method.rb
mailbin-0.1.0 lib/mailbin/delivery_method.rb