class Mail::Message

def add_message_id(msg_id_val = '')

It will preserve the message ID you specify if you do.

specifying a message id.
a unique message ID if you try and encode it or output it to_s without
into the Header. The MessageIdField object will automatically generate
Creates a new empty Message-ID field and inserts it in the correct order
def add_message_id(msg_id_val = '')
  header['message-id'] = msg_id_val
end