utf-8のメールをmail.gemを使って送るとWARNINGが出る。

Non US-ASCII detected and no charset defined.
Defaulting to UTF-8, set your own if this is incorrect.

明示的にcharsetを指定すればOK.

# coding: utf-8
require 'rubygems'
require 'mail'

mail = Mail.new do
  to       'foo@example.com'
  subject  'テスト'
  body     'テストメール'
end

mail.charset = 'utf-8' # It's important!
mail.delivery_method :sendmail
mail.deliver

Comments


Option