kuroda/mail-iso-2022-jp — Issue #2: Rails3.2.1で使用すると例外エラー発生
Author: smajima
Created: 2012-02-15 08:12:54+00:00
State: open

Rails3.2.1 + mail-iso-2022-jp(1.1.4) + ruby1.9.2p290
で日本語メールを送信しようとすると以下の例外が発生します。

Rails3.1.3 + mail-iso-2022-jp(1.1.4) + ruby1.9.2p290
の時は送信できていました。
よろしくお願いします。

Encoding::CompatibilityError (incompatible encoding regexp match (US-ASCII regexp with ISO-2022-JP string)):

■ソースコード

# encoding:utf-8
class SampleMailer < ActionMailer::Base
default from: "susumu.majima@xxxxx.com"
default charset: 'ISO-2022-JP'

# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.sample_mailer.send_japanese.subject
#
def send_japanese
@greeting = "こんにちは"

mail(to: "majima@xxxxxxxxx.co.jp", subject: '日本語のタイトル')
end
end

■framework-trace

mail-iso-2022-jp/ruby/1.9.1/gems/mail-2.4.1/lib/mail/fields/unstructured_field.rb:179:in `gsub!'
mail-iso-2022-jp/ruby/1.9.1/gems/mail-2.4.1/lib/mail/fields/unstructured_field.rb:179:in `encode_crlf'
mail-iso-2022-jp/ruby/1.9.1/gems/mail-2.4.1/lib/mail/fields/unstructured_field.rb:144:in `fold'
mail-iso-2022-jp/ruby/1.9.1/gems/mail-2.4.1/lib/mail/fields/unstructured_field.rb:96:in `wrapped_value'
mail-iso-2022-jp/ruby/1.9.1/gems/mail-2.4.1/lib/mail/fields/unstructured_field.rb:60:in `do_encode'
mail-iso-2022-jp/ruby/1.9.1/gems/mail-2.4.1/lib/mail/fields/unstructured_field.rb:42:in `encoded'
mail-iso-2022-jp/ruby/1.9.1/gems/mail-2.4.1/lib/mail/field.rb:133:in `method_missing'
mail-iso-2022-jp/ruby/1.9.1/gems/mail-2.4.1/lib/mail/header.rb:190:in `block in encoded'
mail-iso-2022-jp/ruby/1.9.1/gems/mail-2.4.1/lib/mail/header.rb:189:in `each'
mail-iso-2022-jp/ruby/1.9.1/gems/mail-2.4.1/lib/mail/header.rb:189:in `encoded'
mail-iso-2022-jp/ruby/1.9.1/gems/mail-2.4.1/lib/mail/message.rb:1707:in `encoded'
mail-iso-2022-jp/ruby/1.9.1/gems/actionmailer-3.2.1/lib/action_mailer/base.rb:433:in `set_payload_for_mail'
mail-iso-2022-jp/ruby/1.9.1/gems/actionmailer-3.2.1/lib/action_mailer/base.rb:413:in `block in deliver_mail'
mail-iso-2022-jp/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/notifications.rb:123:in `block in instrument'
mail-iso-2022-jp/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
mail-iso-2022-jp/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/notifications.rb:123:in `instrument'
mail-iso-2022-jp/ruby/1.9.1/gems/actionmailer-3.2.1/lib/action_mailer/base.rb:412:in `deliver_mail'
mail-iso-2022-jp/ruby/1.9.1/gems/mail-2.4.1/lib/mail/message.rb:229:in `deliver