Strict mode

Since there are plethora of email clients and servers, and there is a historic background of various decisions, it might happen that a client or server break some of the rules defined in various RFC documents. In those situations it is always a question should a software author follow a specification or adapt to the common practice. For that reason, the flag strict mode is introduced to the MIME parser and formatter. By default, it is set to false, meaning that even a specification is not followed in some cases, the Mailio library will try to do a workaround. To switch it on/off, use the method mime::strcit_mode. Here are the cases covered with the flag:

  • The message id must have a format id@domain. In the strict mode, if there is no monkey, the exception is thrown, otherwise the id without @ is accepted.
  • A header must have both name and the value. If the value is empty, in the strict mode the exception is thrown, otherwise the empty value is stored.
  • The content transfer must be set to one of the following values: Base 64, Quoted printable, Seven bit, Eight bit, Binary. If the value is not set or it is invalid, in the strict mode the exception is thrown. In the non-strict mode, the default value of Seven bit is set.
  • The content disposition must be set to either attachment or inline. If not set, in the strict mode the exception is thrown. In the non-strict mode, the default value of attachment is set.
  • The header attribute name and value must be split by the equal character without surrounding spaces. In the non-strict mode, these spaces are ignored.
  • There are seven possible media types, in the strict mode one of them has to be set. If the strict mode is turned off, then the media type is set to none.
  • In the non-strict mode, parsing address handles few invalid situtations.