Send a test email
This commit is contained in:
parent
70ab6cdd98
commit
d0e8d3eba6
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
%% API
|
%% API
|
||||||
-export([start_link/0]).
|
-export([start_link/0]).
|
||||||
|
-export([test/0]).
|
||||||
|
|
||||||
%% gen_server callbacks
|
%% gen_server callbacks
|
||||||
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
|
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
|
||||||
|
@ -35,6 +36,26 @@
|
||||||
start_link() ->
|
start_link() ->
|
||||||
gen_server:start_link(?MODULE, [], []).
|
gen_server:start_link(?MODULE, [], []).
|
||||||
|
|
||||||
|
%%--------------------------------------------------------------------
|
||||||
|
%% @doc
|
||||||
|
%% Send an email to test the configuration.
|
||||||
|
%%
|
||||||
|
%% @spec test() -> binary() | {error, Type, Message}
|
||||||
|
%% @end
|
||||||
|
%%--------------------------------------------------------------------
|
||||||
|
test() ->
|
||||||
|
{ok, EmailConfig} = application:get_env(log_monitor, email_config),
|
||||||
|
Sender = proplists:get_value(sender, EmailConfig),
|
||||||
|
AdminReceiver = proplists:get_value(admin_receiver, EmailConfig),
|
||||||
|
Connection = proplists:get_value(connection, EmailConfig),
|
||||||
|
Subject = "Test",
|
||||||
|
error_logger:info_msg("Sender: ~s, Receiver: ~s, Subject: ~s~n", [Sender, AdminReceiver, Subject]),
|
||||||
|
gen_smtp_client:send_blocking(
|
||||||
|
{Sender, [AdminReceiver],
|
||||||
|
io_lib:format("Subject: ~s\r\nFrom: ~s\r\n\r\nTest~n", [Subject, Sender])},
|
||||||
|
Connection
|
||||||
|
).
|
||||||
|
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
%%% gen_server callbacks
|
%%% gen_server callbacks
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
|
|
Loading…
Reference in New Issue
Block a user