class Mail::Body
def encoded(transfer_encoding = nil)
Calling this directly is not a good idea, but supported for compatibility
identiy encoding (i.e. no encoding).
Returns a body encoded using transfer_encoding. Multipart always uses an
def encoded(transfer_encoding = nil) if multipart? self.sort_parts! encoded_parts = parts.map { |p| p.encoded } ([preamble] + encoded_parts).join(crlf_boundary) + end_boundary + epilogue.to_s else dec = Mail::Encodings.get_encoding(encoding) enc = if Utilities.blank?(transfer_encoding) dec else negotiate_best_encoding(transfer_encoding) end if dec.nil? # Cannot decode, so skip normalization raw_source else # Decode then encode to normalize and allow transforming # from base64 to Q-P and vice versa decoded = dec.decode(raw_source) if defined?(Encoding) && charset && charset != "US-ASCII" decoded = decoded.encode(charset) decoded.force_encoding('BINARY') unless Encoding.find(charset).ascii_compatible? end enc.encode(decoded) end end end