You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
parser: add parts_handler_fn for flexible multipart handling
Replaces max_part_size and skip_large_parts? with a more flexible callback-based approach.
The parts_handler_fn receives part metadata and parsed headers,
allowing conditional parsing based on size, content-type, or any other criteria.
Copy file name to clipboardExpand all lines: lib/mail/parsers/rfc_2822.ex
+81-21Lines changed: 81 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -45,32 +45,88 @@ defmodule Mail.Parsers.RFC2822 do
45
45
46
46
* `:charset_handler` - A function that takes a charset and binary and returns a binary. Defaults to return the string as is.
47
47
* `:header_only` - Whether to parse only the headers. Defaults to false.
48
-
* `:max_part_size` - The maximum size of a part in bytes. Defaults to 10MB.
49
-
* `:skip_large_parts?` - Whether to skip parts larger than `max_part_size`. Defaults to false.
48
+
* `:parts_handler_fn` - A function invoked for each multipart message part. Receives `part_info`, `message` (with parsed headers), and `opts`. Defaults to nil (normal parsing).
50
49
50
+
## Parts Handler Function
51
+
52
+
The `:parts_handler_fn` option allows custom handling of each part in a multipart message:
0 commit comments