mailbox.BabylMessage.set_type

BabylMessage.set_type(type, header='Content-Type', requote=True)

Set the main type and subtype for the Content-Type header.

type must be a string in the form “maintype/subtype”, otherwise a ValueError is raised.

This method replaces the Content-Type header, keeping all the parameters in place. If requote is False, this leaves the existing header’s quoting as is. Otherwise, the parameters will be quoted (the default).

An alternative header can be specified in the header argument. When the Content-Type header is set, we’ll always also add a MIME-Version header.