mikel/mail — Issue #351: Problems creating multipart messages
Author: scottsch
Created: 2012-02-11 01:52:35+00:00
State: open

I am dealing with mail that has been parsed a little already and I want to do further parsing to handle multipart messages. I found one way to do this that works and two more natural ways that don't. By "working", I mean that parts, html_part, and text_part work as I expect.

1) This works: Mail.new("Content-Type: multipart/alternative; ...\r\n\r\nBODY")

2) This doesn't work: Mail.new(:headers => { :content_type => "..." }, :body => "...")
3) Neither does this:
Mail.new do
header "..."
body "..."
end

I looked into the code and I think the reason is because initialize_with_string is the only place that sets @separate_parts, which is used in process_body_raw. #3 doesn't work because it calls initialize_with_hash. #2 doesn't work because initialize runs the block after initialize_with_string.

It seems that you could eliminate @separate_parts and use multipart? instead. I didn't take a stab at this because this is my first day looking at the code, so maybe I'm missing something. Other than this bug, Mail looks well-suited to my needs. Thanks!