class Mail::Message
Attributes
mobile[RW]
Public Instance Methods
add_charset_with_jpmobile()
click to toggle source
# File lib/jpmobile/mail.rb, line 120 def add_charset_with_jpmobile add_charset_without_jpmobile unless multipart? && @mobile end
Also aliased as: add_charset
encoded_with_jpmobile()
click to toggle source
# File lib/jpmobile/mail.rb, line 22 def encoded_with_jpmobile if @mobile header['subject'].mobile = @mobile if header['subject'] header['from'].mobile = @mobile if header['from'] header['to'].mobile = @mobile if header['to'] self.charset = @mobile.mail_charset unless multipart? ready_to_send! self.body.mobile = @mobile self.header['Content-Transfer-Encoding'].value = @mobile.content_transfer_encoding(self.header) if @mobile.decorated? unless self.content_type.match(/image\//) self.header['Content-ID'] = nil end unless self.header['Content-Type'].sub_type == 'mixed' self.header['Date'] = nil self.header['Mime-Version'] = nil end end buffer = header.encoded buffer << "\r\n" buffer = @mobile.utf8_to_mail_encode(buffer) buffer << body.encoded(content_transfer_encoding) ascii_compatible!(buffer) else encoded_without_jpmobile end end
Also aliased as: encoded
find_part_by_content_type(content_type)
click to toggle source
# File lib/jpmobile/mail.rb, line 214 def find_part_by_content_type(content_type) finded_parts = [] self.parts.each do |part| if part.multipart? finded_parts << part.find_part_by_content_type(content_type) elsif part.content_type.match(/^#{content_type}/) finded_parts << part end end finded_parts.flatten end
init_with_hash(hash)
Also aliased as: init_with_hash_without_jpmobile
Alias for: init_with_hash_with_jpmobile
init_with_hash_with_jpmobile(hash)
click to toggle source
# File lib/jpmobile/mail.rb, line 68 def init_with_hash_with_jpmobile(hash) if hash[:body_raw] @mobile = hash[:mobile] init_with_string(hash[:body_raw]) else init_with_hash_without_jpmobile(hash) end end
Also aliased as: init_with_hash
init_with_string(string)
click to toggle source
# File lib/jpmobile/mail.rb, line 80 def init_with_string(string) # convert to ASCII-8BIT for ascii incompatible encodings s = Jpmobile::Util.ascii_8bit(string) self.raw_source = s set_envelope_header parse_message @separate_parts = multipart? end
mobile=(m)
click to toggle source
# File lib/jpmobile/mail.rb, line 16 def mobile=(m) if @mobile = m @charset = m.mail_charset(@charset) end end
parse_message()
Also aliased as: parse_message_without_jpmobile
Alias for: parse_message_with_jpmobile
parse_message_with_jpmobile()
click to toggle source
# File lib/jpmobile/mail.rb, line 55 def parse_message_with_jpmobile header_part, body_part = raw_source.lstrip.split(/#{CRLF}#{CRLF}|#{CRLF}#{WSP}*#{CRLF}(?!#{WSP})/m, 2) # header_part, body_part = raw_source.lstrip.split(HEADER_SEPARATOR, 2) self.header = header_part @body_part_jpmobile = body_part convert_encoding_jpmobile body_part = @body_part_jpmobile self.body = body_part end
Also aliased as: parse_message
process_body_raw()
Also aliased as: process_body_raw_without_jpmobile
Alias for: process_body_raw_with_jpmobile
process_body_raw_with_jpmobile()
click to toggle source
# File lib/jpmobile/mail.rb, line 89 def process_body_raw_with_jpmobile process_body_raw_without_jpmobile if @mobile @body.mobile = @mobile @body.content_type_with_jpmobile = self.content_type if has_content_transfer_encoding? and ["base64", "quoted-printable"].include?(self.content_transfer_encoding) and ["text"].include?(@mobile_main_type) @body.decode_transfer_encoding end if @body.multipart? @body.parts.each do |p| p.mobile = @mobile end end end end
Also aliased as: process_body_raw
raw_source=(value)
click to toggle source
In jpmobile, value is already transfered correctly encodings.
# File lib/jpmobile/mail.rb, line 111 def raw_source=(value) @raw_source = value.to_crlf end
rearrange!()
click to toggle source
– normal multipart/mixed
|- multipart/alternative | |- text/plain | |- text/html | |- image/xxxx (インライン画像) |- image/xxxx (添付画像)
# File lib/jpmobile/mail.rb, line 164 def rearrange! if @mobile and @mobile.decoratable? @mobile.decorated = true text_body_part = find_part_by_content_type("text/plain").first html_body_part = find_part_by_content_type("text/html").first html_body_part.transport_encoding = 'quoted-printable' if html_body_part inline_images = [] attached_files = [] attachments.each do |p| if p.content_type.match(/^image\//) and p.content_disposition.match(/^inline/) if p.header['Content-Type'].parameters['filename'] p.header['Content-Type'].parameters['name'] = p.header['Content-Type'].parameters['filename'].to_s end inline_images << p elsif p.content_disposition attached_files << p end end alternative_part = Mail::Part.new{content_type 'multipart/alternative'} alternative_part.add_part(text_body_part) if text_body_part alternative_part.add_part(html_body_part) if html_body_part if @mobile.require_related_part? related_part = Mail::Part.new{content_type 'multipart/related'} related_part.add_part(alternative_part) inline_images.each do |inline_image| related_part.add_part(inline_image) end inline_images.clear else related_part = alternative_part end unless self.header['Content-Type'].sub_type == 'mixed' self.header['Content-Type'] = self.content_type.gsub(/#{self.header['Content-Type'].sub_type}/, 'mixed') end self.parts.clear self.body = nil self.add_part(related_part) inline_images.each do |inline_image| self.add_part(inline_image) end attached_files.each do |attached_file| self.add_part(attached_file) end end end
separate_parts()
Also aliased as: separate_parts_without_jpmobile
Alias for: separate_parts_with_jpmobile
separate_parts_with_jpmobile()
click to toggle source
# File lib/jpmobile/mail.rb, line 115 def separate_parts_with_jpmobile @body.mobile = @mobile separate_parts_without_jpmobile end
Also aliased as: separate_parts
Private Instance Methods
ascii_compatible!(str)
click to toggle source
# File lib/jpmobile/mail.rb, line 260 def ascii_compatible!(str) Jpmobile::Util.ascii_compatible!(str) end
convert_encoding_jpmobile()
click to toggle source
# File lib/jpmobile/mail.rb, line 229 def convert_encoding_jpmobile # decide mobile carrier if self.header[:from] mobile_class = Jpmobile::Email.detect_from_mail_header(self.header[:from].value) @mobile ||= mobile_class.new(nil, nil) if mobile_class end # override charset if self.header[:content_type] @charset = header[:content_type].parameters[:charset] || '' unless @charset.blank? @mobile_main_type = self.header[:content_type].main_type end end # convert header(s) if header[:subject] && @mobile header[:subject].mobile = @mobile header[:subject].value = header[:subject].decoded end if @body_part_jpmobile and @mobile and !@charset.blank? if ["base64", "quoted-printable"].include?(self.content_transfer_encoding) and self.content_type.match(/text/) @body_part_jpmobile = Jpmobile::Util.decode(@body_part_jpmobile, self.content_transfer_encoding, @charset) self.content_transfer_encoding = @mobile.class::MAIL_CONTENT_TRANSFER_ENCODING end @body_part_jpmobile = @mobile.decode_transfer_encoding(@body_part_jpmobile, @charset) end end