# File lib/mailfactory.rb, line 175
  def construct(options = Hash.new)
    if(options[:date] == nil)
      options[:date] = true
    end
    
    if(options[:messageid])
      # add a unique message-id
      remove_header("Message-ID")
      sendingdomain = get_header('from')[0].to_s()[/@([-a-zA-Z0-9._]+)/,1].to_s()
      add_header("Message-ID", "<#{Time.now.to_f()}.#{Process.euid()}.#{String.new.object_id()}@#{sendingdomain}>")
    end

    if(options[:date])
      if(get_header("Date").length == 0)
        add_header("Date", Time.now.strftime("%a, %d %b %Y %H:%M:%S %z"))
      end
    end

    # Add a mime header if we don't already have one and we have multiple parts
    if(multipart?())
      if(get_header("MIME-Version").length == 0)
        add_header("MIME-Version", "1.0")
      end
      
      if(get_header("Content-Type").length == 0)
        if(@attachments.length == 0)
          add_header("Content-Type", "multipart/alternative;boundary=\"#{@bodyboundary}\"")
        else
          add_header("Content-Type", "multipart/mixed; boundary=\"#{@attachmentboundary}\"")
        end
      end
    end
    
    return("#{headers_to_s()}#{body_to_s()}")
  end