Expand description
The encodings a message has to speak.
Base64, quoted-printable, RFC 2047 encoded-words, header folding, RFC 5322 dates, and SMTP dot-stuffing. None of it is interesting, and all of it is where mail actually breaks: a header that is one byte too long, a body line that starts with a dot, an accented name that arrives as mojibake.
Functions§
- base64_
body - Base64 wrapped at 76 characters with CRLF, which is what a MIME body part must look like — an unwrapped 2 MB single line is not a legal message.
- base64_
decode - base64_
encode - dot_
stuff - Prefix any line that starts with
.with a second one. - encode_
word - Encode a header value as RFC 2047 encoded-words when it is not plain ASCII.
- header_
line - Write
Name: value, folded so no line runs past [HEADER_WIDTH]. - normalize_
crlf - Every line ending becomes CRLF, which is the only line ending a message on the wire is allowed to have.
- percent_
encode - Percent-encode a filename for an RFC 2231
filename*parameter. - quoted_
printable - Encode a body part as quoted-printable (RFC 2045).
- rfc5322_
date - Format a
Date:header, RFC 5322 style, in UTC. - sanitize_
header_ text - Strip anything that would let a value break out of its header.
- unique_
token - A value unique within this process, for boundaries and message ids.