### Build Header Value String (JavaScript) Source: https://github.com/nodemailer/libmime/blob/master/README.md Constructs a header value string from a structured object, typically created by `parseHeaderValue`. It formats the value and its parameters into the standard `value; param1=value1; param2=value2` format. Filenames are encoded if necessary. ```javascript var libmime = require('libmime'); // Example usage: let structuredHeader = { value: 'text/plain', params: { charset: 'UTF-8', boundary: '----zzzz----' } }; let headerString = libmime.buildHeaderValue(structuredHeader); console.log(headerString); // Output: text/plain; CHARSET="UTF-8"; boundary="----zzzz----" ``` -------------------------------- ### Build Header Value with Parameters (JavaScript) Source: https://context7.com/nodemailer/libmime/llms.txt Constructs a structured header value string from a value and its parameters. Automatically handles quoting special characters and RFC 2231 encoding for Unicode filenames. Requires the 'libmime' library. ```javascript const libmime = require('libmime'); // Build simple header const simple = libmime.buildHeaderValue({ value: 'text/plain', params: { charset: 'UTF-8', format: 'flowed' } }); console.log(simple); // Output: text/plain; charset=UTF-8; format=flowed // Build header with special characters (auto-quoted) const special = libmime.buildHeaderValue({ value: 'attachment', params: { filename: 'document a.pdf' } }); console.log(special); // Output: attachment; filename="document a.pdf" // Build header with Unicode filename (RFC 2231 encoding) const unicode = libmime.buildHeaderValue({ value: 'attachment', params: { filename: 'Jõge-vaŽJõge-vaŽJõge-vaŽ.pdf' } }); console.log(unicode); // Output: attachment; filename*0*=utf-8''J%C3%B5ge-va%C5%BDJ%C3%B5ge-va%C5%BDJ; filename*1*=%C3%B5ge-va%C5%BD.pdf ``` -------------------------------- ### buildHeaderValue Source: https://context7.com/nodemailer/libmime/llms.txt Joins a structured header value object back together into a single string, automatically handling quoting and RFC 2231 encoding for parameters. ```APIDOC ## buildHeaderValue ### Description Joins a structured header value object back together as 'value; param1=value1; param2=value2'. Automatically handles quoting special characters and RFC 2231 encoding for Unicode filenames. ### Method `libmime.buildHeaderValue(structuredHeaderValue)` ### Parameters #### Request Body - **structuredHeaderValue** (object) - Required - An object with `value` (string) and `params` (object) properties. - **value** (string) - The main value of the header. - **params** (object) - Key-value pairs for header parameters. ### Request Example ```javascript const libmime = require('libmime'); const simple = libmime.buildHeaderValue({ value: 'text/plain', params: { charset: 'UTF-8', format: 'flowed' } }); console.log(simple); const special = libmime.buildHeaderValue({ value: 'attachment', params: { filename: 'document a.pdf' } }); console.log(special); const unicode = libmime.buildHeaderValue({ value: 'attachment', params: { filename: 'Jõge-vaŽJõge-vaŽJõge-vaŽ.pdf' } }); console.log(unicode); ``` ### Response #### Success Response (string) - **headerValue** (string) - The constructed header value string. #### Response Example ``` text/plain; charset=UTF-8; format=flowed attachment; filename="document a.pdf" attachment; filename*0*=utf-8''J%C3%B5ge-va%C5%BDJ%C3%B5ge-va%C5%BDJ; filename*1*=%C3%B5ge-va%C5%BD.pdf ``` ``` -------------------------------- ### buildHeaderParam Source: https://context7.com/nodemailer/libmime/llms.txt Encodes and splits a header parameter value according to RFC 2231, handling long or non-ASCII values. ```APIDOC ## buildHeaderParam ### Description Encodes and splits a header parameter value according to RFC 2231 Parameter Value Continuations. Useful for long filenames or values containing non-ASCII characters. ### Method `libmime.buildHeaderParam(key, value, maxLength)` ### Parameters #### Path Parameters - **key** (string) - Required - The parameter key. - **value** (string) - Required - The parameter value. - **maxLength** (number) - Required - The maximum length for each parameter part before splitting. ### Request Example ```javascript const libmime = require('libmime'); // Simple ASCII value const simple = libmime.buildHeaderParam('title', 'this is just a title', 500); console.log(simple); // Split long ASCII value const longAscii = libmime.buildHeaderParam('title', 'this is just a title', 5); console.log(longAscii); // Unicode value with continuation encoding const unicode = libmime.buildHeaderParam('filename', 'filename õäöü.txt', 20); console.log(unicode); ``` ### Response #### Success Response (array) - **paramPart** (object) - An array of objects, each representing a part of the parameter. - **key** (string) - The parameter key, potentially with continuation index (e.g., `filename*0*`). - **value** (string) - The encoded or plain value for this part. #### Response Example ```json [ { "key": "title", "value": "this is just a title" } ] [ { "key": "title*0", "value": "this " }, { "key": "title*1", "value": "is ju" }, { "key": "title*2", "value": "st a " }, { "key": "title*3", "value": "title" } ] [ { "key": "filename*0*", "value": "utf-8''filename%20" }, { "key": "filename*1*", "value": "%C3%B5%C3%A4%C3%B6" }, { "key": "filename*2*", "value": "%C3%BC.txt" } ] ``` ``` -------------------------------- ### Detect File Extension from MIME Type - JavaScript Source: https://github.com/nodemailer/libmime/blob/master/README.md Determines the file extension corresponding to a given MIME type string. If no specific extension is found, it defaults to 'bin'. ```javascript libmime.detectExtension(mimeType) ``` -------------------------------- ### decodeHeaders Source: https://context7.com/nodemailer/libmime/llms.txt Parses a block of header lines into an object, mapping header names to arrays of their values. ```APIDOC ## decodeHeaders ### Description Parses a block of header lines into an object where keys are header names and values are arrays (since headers can appear multiple times). Does not decode MIME words. ### Method `libmime.decodeHeaders(headersString)` ### Parameters #### Path Parameters - **headersString** (string) - Required - A string containing multiple header lines. ### Request Example ```javascript const libmime = require('libmime'); const headersStr = 'Subject: Tere =?UTF-8?Q?J=C3=B5geva?=\r\n' + 'X-APP: My app line 1\r\n' + 'X-APP: My app line 2\r\n' + 'Content-Type: text/plain;\r\n' + ' charset=UTF-8'; const headers = libmime.decodeHeaders(headersStr); console.log(headers); // Decode the subject separately if needed console.log(libmime.decodeWords(headers.subject[0])); ``` ### Response #### Success Response (object) - **headerName** (array) - An array of strings, where each string is a value for the corresponding header name. #### Response Example ```json { "subject": ["Tere =?UTF-8?Q?J=C3=B5geva?="], "x-app": ["My app line 1", "My app line 2"], "content-type": ["text/plain; charset=UTF-8"] } Tere Jõgeva ``` ``` -------------------------------- ### decodeHeader Source: https://context7.com/nodemailer/libmime/llms.txt Splits a single header line by the first colon to separate the key and value. It does not decode MIME words. ```APIDOC ## decodeHeader ### Description Splits a single header line by colon and returns the key and value pair. Does not decode MIME words - you need to do your own decoding based on the rules for the specific header key. ### Method `libmime.decodeHeader(headerLine)` ### Parameters #### Path Parameters - **headerLine** (string) - Required - The header line string to decode. ### Request Example ```javascript const libmime = require('libmime'); const header = libmime.decodeHeader('Subject: =?UTF-8?Q?Hello_World?='); console.log(header); const folded = libmime.decodeHeader('Subject: This is a very long\r\n subject line that has been folded'); console.log(folded); ``` ### Response #### Success Response (object) - **key** (string) - The header key (lowercased). - **value** (string) - The header value. #### Response Example ```json { "key": "subject", "value": "=?UTF-8?Q?Hello_World?=" } { "key": "subject", "value": "This is a very long subject line that has been folded" } ``` ``` -------------------------------- ### Parse Header Value with Parameters - JavaScript Source: https://context7.com/nodemailer/libmime/llms.txt Parses a header value containing key=value arguments into a structured object. It correctly handles quoted values and RFC 2231 parameter value continuations, including charset encoding. ```javascript const libmime = require('libmime'); // Parse simple Content-Type header const simple = libmime.parseHeaderValue('text/plain; CHARSET=UTF-8; format=flowed'); console.log(simple); // Output: { value: 'text/plain', params: { charset: 'UTF-8', format: 'flowed' } } // Parse header with quoted values const quoted = libmime.parseHeaderValue('text/plain; filename=";;;\""; format=flowed'); console.log(quoted); // Output: { value: 'text/plain', params: { filename: ';;;"', format: 'flowed' } } // Parse RFC 2231 continuation encoding const continuation = libmime.parseHeaderValue( "text/plain; single_encoded*=\"UTF-8''%C3%95%C3%84%C3%96%C3%9C\";\n" + " multi_encoded*0*=UTF-8''%C3%96%C3%9C;\n" + " multi_encoded*1*=%C3%95%C3%84" ); console.log(continuation); // Output: { value: 'text/plain', params: { single_encoded: 'ÕÄÖÜ', multi_encoded: 'ÖÜÕÄ' } } ``` -------------------------------- ### Decode Multiple Header Lines (JavaScript) Source: https://context7.com/nodemailer/libmime/llms.txt Parses a block of header lines into an object, mapping header names to arrays of their values. Handles repeated headers and basic folding. Requires the 'libmime' library. Does not decode MIME words by default. ```javascript const libmime = require('libmime'); const headersStr = 'Subject: Tere =?UTF-8?Q?J=C3=B5geva?=\r\n' + 'X-APP: My app line 1\r\n' + 'X-APP: My app line 2\r\n' + 'Content-Type: text/plain;\r\n' + ' charset=UTF-8'; const headers = libmime.decodeHeaders(headersStr); console.log(headers); // Output: // { // subject: ['Tere =?UTF-8?Q?J=C3=B5geva?='], // 'x-app': ['My app line 1', 'My app line 2'], // 'content-type': ['text/plain; charset=UTF-8'] // } // Decode the subject console.log(libmime.decodeWords(headers.subject[0])); // Output: Tere Jõgeva ``` -------------------------------- ### Decode Single Header Line (JavaScript) Source: https://context7.com/nodemailer/libmime/llms.txt Splits a single header line into a key-value pair. It does not decode MIME words, requiring separate handling for specific header keys. Handles folded header lines by joining them. Requires the 'libmime' library. ```javascript const libmime = require('libmime'); // Parse single header line const header = libmime.decodeHeader('Subject: =?UTF-8?Q?Hello_World?='); console.log(header); // Output: { key: 'subject', value: '=?UTF-8?Q?Hello_World?=' } // Handle folded header line const folded = libmime.decodeHeader('Subject: This is a very long\r\n subject line that has been folded'); console.log(folded); // Output: { key: 'subject', value: 'This is a very long subject line that has been folded' } ``` -------------------------------- ### MIME Type Detection Source: https://github.com/nodemailer/libmime/blob/master/README.md Provides functions to detect file extensions from MIME types and vice versa. These functions are essential for handling file attachments and content types in emails. ```APIDOC ## MIME Types ### Description Functions for detecting MIME types and file extensions. ### detectExtension #### Description Returns file extension for a content type string. If no suitable extensions are found, 'bin' is used as the default extension. #### Method libmime.detectExtension(mimeType) #### Parameters * **mimeType** (String) - Required - Content type to be checked for #### Response * **String** - The detected file extension (e.g., 'jpeg') #### Example ```javascript libmime.detectExtension('image/jpeg'); // returns 'jpeg' ``` ### detectMimeType #### Description Returns content type for a file extension. If no suitable content types are found, 'application/octet-stream' is used as the default content type. #### Method libmime.detectMimeType(extension) #### Parameters * **extension** (String) - Required - Extension (or filename) to be checked for #### Response * **String** - The detected MIME type (e.g., 'image/jpeg') #### Example ```javascript libmime.detectMimeType('logo.jpg'); // returns 'image/jpeg' ``` ``` -------------------------------- ### foldLines Source: https://context7.com/nodemailer/libmime/llms.txt Folds long lines according to RFC 5322, primarily for headers but also useful for format=flowed text. ```APIDOC ## foldLines ### Description Folds long lines according to RFC 5322. Primarily used for folding header lines to comply with the 76-character line limit, but also useful for format=flowed text. ### Method `libmime.foldLines(text, lineLength, afterSpace)` ### Parameters #### Path Parameters - **text** (string) - Required - The text to fold. - **lineLength** (number) - Optional - The maximum line length (default is 76). - **afterSpace** (boolean) - Optional - If true, preserves trailing spaces for format=flowed text (default is false). ### Request Example ```javascript const libmime = require('libmime'); // Fold a long Content-Type header const contentType = libmime.foldLines( 'Content-Type: multipart/alternative; boundary="----zzzz----"' ); console.log(contentType); // Fold encoded header with line length limit const encoded = libmime.encodeWords( 'Subject: Testin command line kirja õkva kakva mõni tõnis', 'Q', 52 ); const folded = libmime.foldLines(encoded, 76); console.log(folded); // Fold for flowed text const flowed = libmime.foldLines( 'Testin command line kirja õkva kakva mõni tõnis kõllas põllas tõllas rõllas jušla', 76, true ); console.log(flowed); ``` ### Response #### Success Response (string) - **foldedText** (string) - The text with lines folded according to the specified length. #### Response Example ``` Content-Type: multipart/alternative; boundary="----zzzz----" Subject: Testin command line kirja õkva kakva mõni tõnis Testin command line kirja õkva kakva mõni tõnis kõllas põllas tõllas rõllas jušla ``` ``` -------------------------------- ### Detect MIME Type from File Extension - JavaScript Source: https://github.com/nodemailer/libmime/blob/master/README.md Identifies the content type (MIME type) for a given file extension or filename. If no match is found, it defaults to 'application/octet-stream'. ```javascript libmime.detectMimeType(extension) ``` -------------------------------- ### Encode String to MIME Encoded Word (JavaScript) Source: https://github.com/nodemailer/libmime/blob/master/README.md Encodes a string into a MIME encoded word format. Supports specifying the encoding (Q or B) and a maximum length for chunking. Useful for ensuring non-ASCII characters are correctly represented in email headers. ```javascript var libmime = require('libmime'); // Example usage: let encoded = libmime.encodeWord('See on õhin test', 'Q'); console.log(encoded); // Output: =?UTF-8?Q?See_on_=C3=B5hin_test?= ``` -------------------------------- ### Parse Header Value String (JavaScript) Source: https://github.com/nodemailer/libmime/blob/master/README.md Parses a header value string containing `key=value` arguments into a structured object. This is particularly useful for headers like `Content-Type`. Continuation encoded parameters are joined into MIME encoded words. ```javascript var libmime = require('libmime'); // Example usage: let headerValue = 'text/plain; CHARSET="UTF-8"; format=flowed'; let parsed = libmime.parseHeaderValue(headerValue); console.log(parsed); // Output: // { // value: 'text/plain', // params: { // charset: 'UTF-8', // format: 'flowed' // } // } ``` -------------------------------- ### Build Header Parameter with RFC 2231 Encoding (JavaScript) Source: https://context7.com/nodemailer/libmime/llms.txt Encodes and splits a header parameter value according to RFC 2231. This is useful for long filenames or values with non-ASCII characters. The function takes the parameter key, value, and a maximum line length. Requires the 'libmime' library. ```javascript const libmime = require('libmime'); // Simple ASCII value - no encoding needed const simple = libmime.buildHeaderParam('title', 'this is just a title', 500); console.log(simple); // Output: [{ key: 'title', value: 'this is just a title' }] // Split long ASCII value const longAscii = libmime.buildHeaderParam('title', 'this is just a title', 5); console.log(longAscii); // Output: [ // { key: 'title*0', value: 'this ' }, // { key: 'title*1', value: 'is ju' }, // { key: 'title*2', value: 'st a ' }, // { key: 'title*3', value: 'title' } // ] // Unicode value with continuation encoding const unicode = libmime.buildHeaderParam('filename', 'filename õäöü.txt', 20); console.log(unicode); // Output: [ // { key: 'filename*0*', value: "utf-8''filename%20" }, // { key: 'filename*1*', value: '%C3%B5%C3%A4%C3%B6' }, // { key: 'filename*2*', value: '%C3%BC.txt' } // ] ``` -------------------------------- ### Check for Plain Text (JavaScript) Source: https://context7.com/nodemailer/libmime/llms.txt Checks if a string contains only printable 7-bit ASCII characters. Useful for determining if encoding is necessary. This function takes a string as input and returns a boolean indicating if it's plain text. ```javascript const libmime = require('libmime'); // Plain ASCII text console.log(libmime.isPlainText('Hello World')); console.log(libmime.isPlainText('az09\t\r\n~!?')); // Contains non-ASCII characters console.log(libmime.isPlainText('abcõ')); // Contains control characters console.log(libmime.isPlainText('abc\x02')); ``` -------------------------------- ### Encode String to MIME Encoded Word (RFC 2047) - JavaScript Source: https://context7.com/nodemailer/libmime/llms.txt Encodes a string or Buffer into a MIME encoded word (RFC 2047) using Quoted-Printable (Q) or Base64 (B) schemes. Useful for non-ASCII characters in email headers. Supports splitting into multiple words based on a maximum length. ```javascript const libmime = require('libmime'); // Encode with Quoted-Printable (default) const qpEncoded = libmime.encodeWord('See on õhin test'); console.log(qpEncoded); // Output: =?UTF-8?Q?See_on_=C3=B5hin_test?= // Encode with Base64 const b64Encoded = libmime.encodeWord('See on õhin test', 'B'); console.log(b64Encoded); // Output: =?UTF-8?B?U2VlIG9uIMO1aGluIHRlc3Q=?= // Encode with max length to split into multiple words const splitEncoded = libmime.encodeWord('Jõgeva Jõgeva Jõgeva mugeva', 'Q', 20); console.log(splitEncoded); // Output: =?UTF-8?Q?J=C3=B5geva_J=C3=B5geva_J=C3=B5geva_mugeva?= ``` -------------------------------- ### Fold Long Lines According to RFC 5322 (JavaScript) Source: https://context7.com/nodemailer/libmime/llms.txt Folds long lines to comply with RFC 5322, primarily for header lines (76-character limit) and format=flowed text. It can optionally preserve trailing spaces for flowed text. Requires the 'libmime' library. ```javascript const libmime = require('libmime'); // Fold a long Content-Type header const contentType = libmime.foldLines( 'Content-Type: multipart/alternative; boundary="----zzzz----"' ); console.log(contentType); // Output: // Content-Type: multipart/alternative; // boundary="----zzzz----" // Fold encoded header with line length limit const encoded = libmime.encodeWords( 'Subject: Testin command line kirja õkva kakva mõni tõnis', 'Q', 52 ); const folded = libmime.foldLines(encoded, 76); console.log(folded); // Multiple lines, each under 76 characters // Fold for flowed text (afterSpace=true keeps space at line end) const flowed = libmime.foldLines( 'Testin command line kirja õkva kakva mõni tõnis kõllas põllas tõllas rõllas jušla', 76, true ); console.log(flowed); // Lines end with space before CRLF for format=flowed ``` -------------------------------- ### Decode Multiple Header Lines (JavaScript) Source: https://github.com/nodemailer/libmime/blob/master/README.md Parses a block of email header lines into an object where keys are header names and values are arrays of header values. It does not perform MIME word decoding, as each header type may have specific decoding rules. ```javascript var libmime = require('libmime'); // Example usage: let headersString = 'Subject: Test\nFrom: sender@example.com\nTo: recipient@example.com'; let decodedHeaders = libmime.decodeHeaders(headersString); console.log(decodedHeaders); // Output: { subject: ['Test'], from: ['sender@example.com'], to: ['recipient@example.com'] } ``` -------------------------------- ### Decode Single Header Line (JavaScript) Source: https://github.com/nodemailer/libmime/blob/master/README.md Unfolds a single email header line, which might contain linebreaks, and splits it into a key-value pair. The returned value is not MIME word decoded, requiring separate handling. ```javascript var libmime = require('libmime'); // Example usage: let headerLine = 'Subject: =?UTF-8?Q?This_is_a_test_subject?='; let decodedHeader = libmime.decodeHeader(headerLine); console.log(decodedHeader); // Output: { key: 'subject', value: '=?UTF-8?Q?This_is_a_test_subject?=' } ``` -------------------------------- ### Decode format=flowed Text (JavaScript) Source: https://github.com/nodemailer/libmime/blob/master/README.md Unwraps plaintext strings that were formatted using the `format=flowed` standard. It can optionally delete leading spaces from lines, as per the `delsp` option. ```javascript var libmime = require('libmime'); // Example usage: let flowedText = 'This is a very long line that\nneeds to be wrapped according to the flowed format.'; let decodedFlowed = libmime.decodeFlowed(flowedText); console.log(decodedFlowed); ``` -------------------------------- ### Encode Header Parameter (RFC2231) - JavaScript Source: https://github.com/nodemailer/libmime/blob/master/README.md Encodes and splits a header parameter value according to RFC2231. It takes a key, a string or buffer value, and an optional maximum length for encoded parts. It returns an array of objects, each containing a key and its encoded value. ```javascript libmime.buildHeaderParam(key, str, maxLength) ``` -------------------------------- ### Decode MIME Encoded Words (JavaScript) Source: https://github.com/nodemailer/libmime/blob/master/README.md Decodes a string that may contain one or more MIME encoded words back into their original form. If no encoded words are found, the original string is returned. This is essential for interpreting received email content. ```javascript var libmime = require('libmime'); // Example usage: let decoded = libmime.decodeWords('=?UTF-8?Q?See_on_=C3=B5hin_test?='); console.log(decoded); // Output: See on õhin test ``` -------------------------------- ### Check for Long Lines (JavaScript) Source: https://context7.com/nodemailer/libmime/llms.txt Checks if a multi-line string contains any line longer than the specified length. Useful for determining if line wrapping is needed. This function takes a multi-line string and a maximum line length as input, returning a boolean. ```javascript const libmime = require('libmime'); // No lines exceed limit console.log(libmime.hasLongerLines('abc\ndef', 5)); // One line exceeds limit console.log(libmime.hasLongerLines('juf\nabcdef\nghi', 5)); // Check against 76-char limit (RFC 5322) const email = 'This is a short line\nThis is also short'; console.log(libmime.hasLongerLines(email, 76)); ``` -------------------------------- ### Header Parameter Encoding Source: https://github.com/nodemailer/libmime/blob/master/README.md Encodes and splits a header parameter value according to RFC2231 for parameter value continuations. This function is useful for handling special characters and long parameter values in email headers. ```APIDOC ## buildHeaderParam ### Description Encodes and splits a header param value according to RFC2231 Parameter Value Continuations. ### Method libmime.buildHeaderParam(key, str, maxLength) ### Parameters #### Path Parameters * None #### Query Parameters * None #### Request Body * **key** (String) - Required - Parameter key (eg. `filename`) * **str** (String | Buffer) - Required - String or an Buffer value to encode * **maxLength** (Number) - Optional - Maximum length of the encoded string part (not line length). Defaults to 50 ### Request Example ```json { "key": "filename", "str": "filename õäöü.txt", "maxLength": 20 } ``` ### Response #### Success Response (200) - **Array** - An array of encoded parts with the following structure: `[{key:'...', value: '...'}]` #### Response Example ```json [ { "key": "filename*0*", "value": "utf-8''filename%20" }, { "key": "filename*1*", "value": "%C3%B5%C3%A4%C3%B6" }, { "key": "filename*2*", "value": "%C3%BC.txt" } ] ``` ``` -------------------------------- ### Encode Non-ASCII Characters to MIME Words (JavaScript) Source: https://github.com/nodemailer/libmime/blob/master/README.md Encodes only the non-ASCII sequences within a string to MIME encoded words. This function helps in preparing email content or headers that contain international characters for transmission. ```javascript var libmime = require('libmime'); // Example usage: let encoded = libmime.encodeWords('Hello, world! Привет, мир!'); console.log(encoded); // Output might be: Hello, world! =?UTF-8?Q?...?= ``` -------------------------------- ### Fold Long Lines According to RFC 5322 (JavaScript) Source: https://github.com/nodemailer/libmime/blob/master/README.md Folds long lines in a string to comply with RFC 5322 standards, typically used for email header lines. It allows specifying a maximum line length and an option to add a space at the end of folded lines. ```javascript var libmime = require('libmime'); // Example usage: let longLine = 'Content-Type: multipart/alternative; boundary="----zzzz----"'; let folded = libmime.foldLines(longLine); console.log(folded); // Output: // Content-Type: multipart/alternative; // boundary="----zzzz----" ``` -------------------------------- ### Encode Text with format=flowed (JavaScript) Source: https://github.com/nodemailer/libmime/blob/master/README.md Adds soft line breaks to a plaintext string marked with `format=flowed` options, ensuring no line exceeds a specified maximum length. This is used for creating flowed text in emails. ```javascript var libmime = require('libmime'); // Example usage: let text = 'This is a very long line that needs to be wrapped according to the flowed format.'; let encodedFlowed = libmime.encodeFlowed(text, 76); console.log(encodedFlowed); ``` -------------------------------- ### Decode MIME Encoded Words - JavaScript Source: https://context7.com/nodemailer/libmime/llms.txt Decodes strings containing one or more MIME encoded words (RFC 2047). It automatically handles both Quoted-Printable and Base64 schemes and joins adjacent encoded words with the same charset. ```javascript const libmime = require('libmime'); // Decode Quoted-Printable encoded words const decoded = libmime.decodeWords('Hello: =?UTF-8?q?See_on_=C3=B5hin_test?='); console.log(decoded); // Output: Hello: See on õhin test // Decode Base64 encoded words const b64decoded = libmime.decodeWords('=?UTF-8?B?U2VlIG9uIMO1aGluIHRlc3Q=?='); console.log(b64decoded); // Output: See on õhin test // Decode Chinese characters with multiple encoded words const chinese = libmime.decodeWords('=?gb2312?B?z/u30czh0NHIq8Pmyf28ti3Dv8jV0MXTw7ncvNK5qcT6x+HLybbU1csswNbP?=\r\n =?gb2312?B?7dDFz6Ih?='); console.log(chinese); // Output: 消费提醒全面升级-每日信用管家供您轻松对账,乐享信息! // Decode Japanese ISO-2022-JP const japanese = libmime.decodeWords('=?ISO-2022-JP?B?GyRCM1g5OzU7PVEwdzgmPSQ4IUYkMnFKczlwGyhC?='); console.log(japanese); // Output: 学校技術員研修検討会報告 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.