Handling Message-ID with templates better

Uses the header if it's defined in the template, unless :message_id is
explicitly passed