bcc / cc in envelope
This commit is contained in:
parent
905405a46e
commit
fe8e2dfbe9
@ -14,17 +14,17 @@ defmodule Mailex do
|
|||||||
config = Keyword.merge(@config_defaults, config || [])
|
config = Keyword.merge(@config_defaults, config || [])
|
||||||
|
|
||||||
message = email |> Mailex.Render.render
|
message = email |> Mailex.Render.render
|
||||||
from = email.from |> Mailex.Address.envelope_format
|
envelope_from = email.from |> Mailex.Address.envelope_format
|
||||||
to = email.to |> Mailex.Address.envelope_format
|
envelope_to = email.to ++ (email.cc || []) ++ (email.bcc || [])
|
||||||
|
|
||||||
if Keyword.get(config, :relay) do
|
if Keyword.get(config, :relay) do
|
||||||
envelope = { from, to, message }
|
envelope = { envelope_from, envelope_to, message }
|
||||||
case :gen_smtp_client.send_blocking(envelope, config) do
|
case :gen_smtp_client.send_blocking(envelope, config) do
|
||||||
{ :error, msg } -> { :error, msg }
|
{ :error, msg } -> { :error, msg }
|
||||||
msg -> { :ok, msg }
|
msg -> { :ok, msg }
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
IO.puts "\n\n[[[ Mailex ]]]\n\nFROM: #{from}\nTO: #{to}\n\nRAW START -------------\n#{message}\nRAW END -------------\n\n"
|
IO.puts "\n\n[[[ Mailex ]]]\n\nFROM: #{envelope_from}\nTO: #{envelope_to}\n\nRAW START -------------\n#{message}\nRAW END -------------\n\n"
|
||||||
{:ok, "message dumped to console"}
|
{:ok, "message dumped to console"}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -18,7 +18,7 @@ defmodule Mailex.Address do
|
|||||||
List.first |>
|
List.first |>
|
||||||
String.split(~r/([^\w\s]|_)/) |>
|
String.split(~r/([^\w\s]|_)/) |>
|
||||||
Enum.map(&String.capitalize/1) |>
|
Enum.map(&String.capitalize/1) |>
|
||||||
Enum.join " "
|
Enum.join(" ")
|
||||||
"#{name} <#{email_address}>"
|
"#{name} <#{email_address}>"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -112,8 +112,7 @@ defmodule Mailex.Render do
|
|||||||
if email.reply_to && (length(email.reply_to) > 0), do:
|
if email.reply_to && (length(email.reply_to) > 0), do:
|
||||||
headers = [ { "Reply-To", email.reply_to |> stringify_addresses } ]
|
headers = [ { "Reply-To", email.reply_to |> stringify_addresses } ]
|
||||||
|
|
||||||
if email.bcc && (length(email.bcc) > 0), do:
|
# BCC should not go into headers
|
||||||
headers = [ { "Bcc", email.bcc |> stringify_addresses } | headers ]
|
|
||||||
|
|
||||||
if email.cc && (length(email.cc) > 0), do:
|
if email.cc && (length(email.cc) > 0), do:
|
||||||
headers = [ { "Cc", email.cc |> stringify_addresses } | headers ]
|
headers = [ { "Cc", email.cc |> stringify_addresses } | headers ]
|
||||||
|
Loading…
Reference in New Issue
Block a user