add_message_id (RMail::Header)

    # File lib/rmail/header.rb, line 771
        def add_message_id(fqdn = nil)

          # If they don't supply a fqdn, we supply one for them.
          #
          # First grab the From: field and see if we can use a domain from
          # there.  If so, use that domain name plus the hash of the From:
          # field's value (this guarantees that bob@example.com and
          # sally@example.com will never have clashes).
          #
          # If there is no From: field, grab the current host name and use
          # some randomness from Ruby's random number generator.  Since
          # Ruby's random number generator is fairly good this will
          # suffice so long as it is seeded corretly.
          #
          # P.S. There is no portable way to get the fully qualified
          # domain name of the current host.  Those truly interested in
          # generating "correct" message-ids should pass it in.  We
          # generate a hopefully random and unique domain name.
          unless fqdn
            unless fqdn = from.domains.first
              require 'socket'
              fqdn = sprintf("%s.invalid", Socket.gethostname)
            end
          else
            raise ArgumentError, "fqdn must have at least one dot" unless
              fqdn.index('.')
          end

          # Hash the header we have so far.
          md5 = Digest::MD5.new
          starting_digest = md5.digest
          @fields.each { |f|
            if f.raw
              md5.update(f.raw)
            else
              md5.update(f.name) if f.name
              md5.update(f.value) if f.value
            end
          }
          if (digest = md5.digest) == starting_digest
            digest = 0
          end

          set('Message-Id', sprintf("<%s.%s.%s.rubymail@%s>",
                                    base36(Time.now.to_i),
                                    base36(rand(MESSAGE_ID_MAXRAND)),
                                    base36(digest),
                                    fqdn))
        end