Sha256: 468c892ea23b165bc3a814f7e761a75d54ddaae6d3c4b72df920d1d5c339c9b3

Contents?: true

Size: 1.35 KB

Versions: 19

Compression:

Stored size: 1.35 KB

Contents

# -*- coding: utf-8 -*-
require 'jpmobile/mail'
require 'jpmobile/lookup_context'

Jpmobile::Email.japanese_mail_address_regexp = Regexp.new(/\.jp[^a-zA-Z\.\-]/)

module Jpmobile
  module Mailer
    class Base < ActionMailer::Base
      self._view_paths = self._view_paths.dup
      self.view_paths.unshift(Jpmobile::Resolver.new(File.join(::Rails.root, "app/views")))

      def mail(headers={}, &block)
        tos = headers[:to] || self.default_params[:to]
        tos = tos.split(/,/)

        @mobile = if tos.size == 1
                    # for mobile
                    (Jpmobile::Email.detect(tos.first) || Jpmobile::Mobile::AbstractMobile).new(nil, nil)
                  else
                    # for multi to addresses
                    Jpmobile::Mobile::AbstractMobile.new(nil, nil)
                  end
        self.lookup_context.mobile = @mobile.variants

        @mobile.decorated = headers.delete(:decorated)

        m = super(headers, &block)

        m.mobile  = @mobile
        m.charset = @mobile.mail_charset

        # for decorated-mail manipulation
        m.rearrange! if @mobile.decorated?

        m
      end

      class << self
        protected
        def set_payload_for_mail(payload, mail) #:nodoc:
          super

          payload[:mail] = Jpmobile::Util.ascii_8bit(mail.encoded).gsub(/\r\n/, "\n")
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
jpmobile-1.0.12 lib/jpmobile/mailer.rb
jpmobile-1.0.11 lib/jpmobile/mailer.rb
jpmobile-1.0.10 lib/jpmobile/mailer.rb
jpmobile-2.0.9 lib/jpmobile/mailer.rb
jpmobile-3.0.5 lib/jpmobile/mailer.rb
jpmobile-1.0.9 lib/jpmobile/mailer.rb
jpmobile-2.0.8 lib/jpmobile/mailer.rb
jpmobile-3.0.4 lib/jpmobile/mailer.rb
jpmobile-3.0.3 lib/jpmobile/mailer.rb
jpmobile-3.0.2 lib/jpmobile/mailer.rb
jpmobile-3.0.1 lib/jpmobile/mailer.rb
jpmobile-2.0.7 lib/jpmobile/mailer.rb
jpmobile-2.0.6 lib/jpmobile/mailer.rb
jpmobile-3.0.0 lib/jpmobile/mailer.rb
jpmobile-2.0.5 lib/jpmobile/mailer.rb
jpmobile-1.0.8 lib/jpmobile/mailer.rb
jpmobile-2.0.4 lib/jpmobile/mailer.rb
jpmobile-2.0.3 lib/jpmobile/mailer.rb
jpmobile-1.0.7 lib/jpmobile/mailer.rb