Class: TMail::MimeEncodeSingle

Inherits:
Object
  • Object
show all
Defined in:
lib/tmail/net.rb

Overview

:stopdoc:

Instance Method Summary collapse

Instance Method Details

#exec(mail) ⇒ Object


207
208
209
210
211
212
213
214
215
# File 'lib/tmail/net.rb', line 207

def exec( mail )
  mail.mime_version = '1.0'
  b = mail.body
  if NKF.guess(b) != NKF::BINARY
    on_text b
  else
    on_binary b
  end
end

#on_binary(body) ⇒ Object


223
224
225
226
227
# File 'lib/tmail/net.rb', line 223

def on_binary( body )
  mail.body = [body].pack('m')
  mail.set_content_type 'application', 'octet-stream'
  mail.encoding = 'Base64'
end

#on_text(body) ⇒ Object


217
218
219
220
221
# File 'lib/tmail/net.rb', line 217

def on_text( body )
  mail.body = NKF.nkf('-j -m0', body)
  mail.set_content_type 'text', 'plain', {'charset' => 'iso-2022-jp'}
  mail.encoding = '7bit'
end