Module z_email_server

Email server.

Copyright © 2010-2020 Maximonster Interactive Things

Behaviours: gen_server.

Authors: Marc Worrell (marc@worrell.nl), Atilla Erdodi (atilla@maximonster.com).

Description

Email server. Queues, renders and sends e-mails.

Data Types

delivery_type()

delivery_type() = permanent_failure | temporary_failure | sent | received | relayed

Function Index

bounced/2Handle a bounce.
code_change/3Convert process state when code is changed.
delivery_report/4Handle a delivery report from an outside service like mailgun.
generate_message_id/0Generate a new message id.
get_email_from/1
handle_call/3
handle_cast/2Send an e-mail.
handle_info/2Poll the database queue for any retrys.
init/1Initiates the server.
is_bounce_email_address/1Check if the received e-mail address is a bounce address.
is_recipient_blocked/2
is_sender_enabled/2Check if the sender is allowed to send email.
is_sender_enabled/3
is_tempfile/1Check if a file is a tempfile of the emailer.
is_tempfile_deletable/1Return the max age of a tempfile.
poll/0Force a poll to send new email.
send/2Send an email.
send/3Send an email using a predefined unique id.
start_link/0Starts the server.
tempfile/0Return the filename for a tempfile that can be used for the emailer.
terminate/2This function is called by a gen_server when it is about to terminate.

Function Details

bounced/2

bounced(Peer, NoReplyEmail) -> any()

Handle a bounce

code_change/3

code_change(OldVsn, State, Extra) -> {ok, NewState}

Convert process state when code is changed

delivery_report/4

delivery_report(What::delivery_type(), OptRecipient::binary() | undefined, MsgIdHeader::binary(), OptStatusMessage::binary() | undefined) -> ok

Handle a delivery report from an outside service like mailgun

generate_message_id/0

generate_message_id() -> binary()

Generate a new message id

get_email_from/1

get_email_from(Context::z:context()) -> binary()

handle_call/3

handle_call(Message::Request, From, State) -> {reply, Reply, State} | {reply, Reply, State, Timeout} | {noreply, State} | {noreply, State, Timeout} | {stop, Reason, Reply, State} | {stop, Reason, State}

handle_cast/2

handle_cast(Message::Msg, State) -> {noreply, State} | {noreply, State, Timeout} | {stop, Reason, State}

Send an e-mail.

handle_info/2

handle_info(Info, State) -> {noreply, State} | {noreply, State, Timeout} | {stop, Reason, State}

Poll the database queue for any retrys.

init/1

init(Args) -> {ok, State} | {ok, State, Timeout} | ignore | {stop, Reason}

Initiates the server.

is_bounce_email_address/1

is_bounce_email_address(X1) -> any()

Check if the received e-mail address is a bounce address

is_recipient_blocked/2

is_recipient_blocked(Recipient, Context) -> any()

is_sender_enabled/2

is_sender_enabled(Email, Context) -> any()

Check if the sender is allowed to send email. If an user is disabled they are only allowed to send mail to themselves or to the admin.

is_sender_enabled/3

is_sender_enabled(Id, RecipientEmail, Context) -> any()

is_tempfile/1

is_tempfile(File) -> any()

Check if a file is a tempfile of the emailer

is_tempfile_deletable/1

is_tempfile_deletable(File) -> any()

Return the max age of a tempfile

poll/0

poll() -> ok

Force a poll to send new email

send/2

send(Email, Context) -> any()

Send an email

send/3

send(EmailId, Email, Context) -> any()

Send an email using a predefined unique id.

start_link/0

start_link() -> {ok, Pid} | ignore | {error, Error}

Starts the server

tempfile/0

tempfile() -> any()

Return the filename for a tempfile that can be used for the emailer

terminate/2

terminate(Reason, State) -> void()

This function is called by a gen_server when it is about to terminate. It should be the opposite of Module:init/1 and do any necessary cleaning up. When it returns, the gen_server terminates with Reason. The return value is ignored.


Generated by EDoc