private static void encodeAddresses(
            ByteBuf buffer,
            Collection<MailAddress> addresses,
            int posInLine) {
        boolean isFirstAddress = true;
        for (MailAddress addr : addresses) {
            if (isFirstAddress) {
                isFirstAddress = false;
            } else {
                buffer.writeByte(',');
                posInLine++;
            }
            String address = addr.address();
            String name = addr.name();
            int addressLength = address.length();
            if (posInLine + addressLength >= SOFT_LINE_LIMIT_EXCLUDING_CRLF_WHITESPACE) {
                buffer.writeBytes(CRLF_SPACE);
                posInLine = 1;
            }
            buffer.writeBytes(StringUtil.getBytes(address));
            posInLine += addressLength;
            if (name == null || name.isEmpty()) {
                continue;
            }
            if (shouldEncodeQuotedPrintableOrWrap(name, posInLine)) {
                boolean hadSpace = false;
                if (posInLine + 12 >= 71) {
                    buffer.writeBytes(CRLF_SPACE);
                    posInLine = 1;
                    hadSpace = true;
                }
                if (!hadSpace) {
                    buffer.writeByte(' ');
                    posInLine++;
                }
                buffer.writeByte('(');
                posInLine++;
                posInLine = encodeQuotedPrintableHeader(buffer, name, posInLine);
                buffer.writeByte(')');
                posInLine++;
            } else {
                boolean hadSpace = false;
                if (posInLine + name.length() + 3 >= SOFT_LINE_LIMIT_EXCLUDING_CRLF_WHITESPACE) {
                    buffer.writeBytes(CRLF_SPACE);
                    posInLine = 1;
                    hadSpace = true;
                }
                if (!hadSpace) {
                    buffer.writeByte(' ');
                    posInLine++;
                }
                buffer.writeByte('(');
                posInLine++;
                buffer.writeBytes(StringUtil.getBytes(name));
                buffer.writeByte(')');
                posInLine += addressLength + 3;
            }
        }
    }
https://www.rfc-editor.org/rfc/rfc5322#section-3.4
https://www.rfc-editor.org/rfc/rfc5322#section-3.6.2
turms-plugins/turms-plugin-push/src/main/java/im/turms/plugin/push/core/smtp/codec/MailEncoder.java