From f40ecb33f881acbb9d46e6543dffd1993f6dd344 Mon Sep 17 00:00:00 2001 From: Dejan Strbac Date: Wed, 23 Dec 2015 19:02:56 +0100 Subject: [PATCH] add extra headers --- lib/mailex/email.ex | 2 +- lib/mailex/render.ex | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) 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