def add_headers(msg, headers):
    """Add headers to a Message object.

       msg is an email.message.Message object.

       headers is a dictionary of headers and values.
       """
    if headers:
        for k in sorted(headers.keys()):
            del msg[k]
            msg[k] = headers[k]
