Skip to content

Commit 6812335

Browse files
AwlexAlex Wieser
Awlex
authored and
Alex Wieser
committed
filter attachment text parts
1 parent f3ef62d commit 6812335

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/mail/renderers/rfc_2822.ex

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
defmodule Mail.Renderers.RFC2822 do
2-
import Mail.Message, only: [match_content_type?: 2]
2+
import Mail.Message, only: [match_content_type?: 2, is_attachment?: 1]
33

44
@days ~w(Mon Tue Wed Thu Fri Sat Sun)
55
@months ~w(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)
@@ -255,7 +255,12 @@ defmodule Mail.Renderers.RFC2822 do
255255
content_type = Mail.Message.get_content_type(message)
256256

257257
if Mail.Message.has_attachment?(message) do
258-
text_parts = Enum.filter(message.parts, &match_content_type?(&1, ~r/text\/(plain|html)/))
258+
text_parts =
259+
Enum.filter(
260+
message.parts,
261+
&(match_content_type?(&1, ~r/text\/(plain|html)/) and not is_attachment?(&1))
262+
)
263+
259264
content_type = List.replace_at(content_type, 0, "multipart/mixed")
260265
message = Mail.Message.put_content_type(message, content_type)
261266

0 commit comments

Comments
 (0)