class Mail::Message
def text_part=(msg)
html_part are both defined in a message, then it will be a multipart/alternative
Helper to add a text part to a multipart/alternative email. If this and
def text_part=(msg) # Assign the text part and set multipart/alternative if there's an html part. if msg msg = Mail::Part.new(:body => msg) unless msg.kind_of?(Mail::Message) @text_part = msg @text_part.content_type = 'text/plain' unless @text_part.has_content_type? add_multipart_alternate_header if html_part add_part @text_part # If nil, delete the text part and back out of multipart/alternative. elsif @text_part parts.delete_if { |p| p.object_id == @text_part.object_id } @text_part = nil if html_part self.content_type = nil body.boundary = nil end end end