diff --git a/lib/mailex/email.ex b/lib/mailex/email.ex index 504db55..d3e1ea0 100644 --- a/lib/mailex/email.ex +++ b/lib/mailex/email.ex @@ -1,5 +1,5 @@ defmodule Mailex.Email do - defstruct subject: nil, from: nil, reply_to: nil, to: nil, cc: nil, bcc: nil, attachments: nil, html: nil, text: nil + defstruct subject: nil, from: nil, reply_to: nil, to: nil, cc: nil, bcc: nil, headers: nil, attachments: nil, html: nil, text: nil end diff --git a/lib/mailex/render.ex b/lib/mailex/render.ex index 64d9b30..be78136 100644 --- a/lib/mailex/render.ex +++ b/lib/mailex/render.ex @@ -121,6 +121,9 @@ defmodule Mailex.Render do if email.to && (length(email.to) > 0), do: headers = [ { "To", email.to |> stringify_addresses } | headers ] + if email.headers && (length(email.headers) > 0), do: + headers = headers ++ email.headers + [ { "From", email.from |> stringify_addresses }, { "Subject", email.subject || "" } | headers ] end