Skip to content

Commit dd4eea8

Browse files
committed
Fix reply-to → Reply-To, which prevented mimemail from encoding the header properly
1 parent daa8702 commit dd4eea8

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

lib/mailman/parsing.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ defmodule Mailman.Parsing do
1111
subject: get_header(raw, "Subject") || "",
1212
from: get_header(raw, "From") || "",
1313
to: get_header(raw, "To") || "",
14-
reply_to: get_header(raw, "reply-to") || "",
14+
reply_to: get_header(raw, "Reply-To") || "",
1515
cc: get_header(raw, "Cc") || "",
1616
bcc: get_header(raw, "Bcc") || "",
1717
attachments: get_attachments(raw),

lib/mailman/render.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ defmodule Mailman.Render do
130130
{ "From", email.from },
131131
{ "To", email.to |> normalize_addresses |> Enum.join(",") },
132132
{ "Subject", email.subject },
133-
{ "reply-to", email.reply_to },
133+
{ "Reply-To", email.reply_to },
134134
{ "Cc", email.cc |> as_list |> normalize_addresses |> Enum.join(", ") |> as_list },
135135
{ "Bcc", email.bcc |> as_list |> normalize_addresses |> Enum.join(", ") |> as_list }
136136
] |> Enum.filter(fn(i) -> elem(i, 1) != [] end)

test/mailman_test.exs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ defmodule MailmanTest do
9393
{:ok, message} = MyApp.Mailer.deliver(testing_email())
9494
{:ok, parsed_email} = Mailman.Email.parse(message)
9595

96-
IO.inspect("PARSED EMAIL IS #{inspect parsed_email}")
96+
# Un-comment this to investigate problems with parsing
97+
# IO.inspect(parsed_email)
9798

9899
assert true
99100
end
@@ -335,4 +336,27 @@ defmodule MailmanTest do
335336
email_with_template_paths.data
336337
)
337338
end
339+
340+
def email_with_unicode_in_header do
341+
%Mailman.Email{
342+
subject: "Hello Mailman!",
343+
from: "Some Emoji – 👍 <mailman@elixir.com>",
344+
reply_to: "Some more Emoji – 🔥 <reply@example.com>",
345+
to: ["Another Emoji – 💕 <ciemniewski.kamil@gmail.com>"],
346+
cc: ["Another Emoji! – 🎁 <testy2#tester1234.com>", "abcd@defd.com"],
347+
bcc: ["Yet another emoji! – 🌹 <1234@wsd.com>", "Just ASCII <test@example.com>"],
348+
text: "Yo, here's one more emoji: 🆕",
349+
html: "<div>Yo, here's one more emoji: 🆕</div>",
350+
}
351+
end
352+
353+
test "should encode email parts properly" do
354+
email_with_unicode_in_header = email_with_unicode_in_header()
355+
rendered_email = Mailman.Render.render(email_with_unicode_in_header, %Mailman.EexComposeConfig{})
356+
357+
# Un-comment this to investigate problems with header encodings
358+
# IO.inspect(rendered_email)
359+
360+
assert true
361+
end
338362
end

0 commit comments

Comments
 (0)