hi,
i have this from an app i have done before.
not sure how it behave now with latest CB.
ail
├── view
│ ├── notification.html
│ └── notification.txt
├── myapp_mail_incoming_mail_controller.erl
└── myapp_mail_outgoing_mail_controller.erl
-module(myapp_mail_outgoing_mail_controller).
-export ([notification/1]).
notification(Email) ->
{
ok,
Email:from(),
Email:to(),
Email:headers(),
Email:attributes(),
[{charset, "utf-8"}]
}.
%%% ----- mail model
-module(mail, [Id,
FromName,
From,
To,
ToName,
Subject,
Message,
Html,
DateCreated,
Charset,
Lang
]).
-define (MAIL_FROM, "
no-r...@mydomain.com").
-define (MAIL_NAME, "MYDOMAIN Mail System").
-export([humanize_from/0]).
-export([b64_subject/0]).
-export([headers/0]).
humanize_from() ->
case THIS:from_name() of
undefined -> THIS:from();
Name -> string:join ([Name, " <", THIS:from(), ">"], "")
end.
b64_subject() ->
SubjB64 = base64:encode_to_string (THIS:subject()),
string:join(["=?UTF-8?B?", SubjB64, "?="], "").
headers() ->
[
{ "To", THIS:to()},
{ "From", THIS:humanize_from()},
{ "Subject", THIS:b64_subject()},
%{"Content-Language", THIS:lang()},
{ "Content-Type", "text/plain; charset=UTF-8"}
].
here the basic call to send the mail:
do_sendmail(EmailAttrs) ->
M = boss_record:new(mail, EmailAttrs),
{ok, EMail} = M:save(),
boss_mail:send_template(vikvon_mail, notification, [EMail]).
mihawk.