The SMTP client is very simple, but is capable of sending e-mail via a standard SMTP server. If something unexpected happens, the entire e-mail transaction is aborted.
The SMTP server is likewise trivial, and does not constitute a full-fledged mail server. A specified callback function is called for each piece of incoming mail received.
This module was previously called smtpe
.
Exported Functions | |
---|---|
client/9 | Called by send_email/1 . |
send_email/1 | Sends an e-mail message to an SMTP server. |
server/1 | Starts a simple SMTP server. |
server/4 | Called by server/1 . |
Internal Documented Functions | |
eol/0 | Returns the internet line terminator sequence. |
escape/1 | Escapes a line per RFC 821, prepending a period if need be. |
expect/2 | Expects a given return-code from the SMTP server. |
get_line/1 | Gets a line of text from the given socket. |
get_opt/3 | Gets an SMTP option. |
send_line/2 | Sends a line of text to the given socket. |
client(socket(), pid(), Originator::string(), Sender::string(), Recipients::[string()], Message::string(), MessageID::string(), Headers::[string()], Subject::string()) -> exit
Called by send_email/1
. Should not be called directly by user code.
send_email([option()]) -> ok | {error, Reason}
Sends an e-mail message to an SMTP server. Options include:
{host, string()}
the name of the host that the SMTP server is running on.
{port, string()}
the port on the host that is running the SMTP service, if not 25.
{originator, string()}
the name of the host that is originating the transaction (i.e., this host.)
{sender, string()}
the e-mail address of the message sender.
{recipients, [string()]}
the e-mail addresses of the message recipients.
{subject, string()}
the subject of the message.
{headers, [string()]}
custom e-mail headers in the form "Header: value"
,
one header per string.
{message, [string()]}
the body of the e-mail message to send, one line per string.
server([option()]) -> {ok, Pid} | {error, Reason}
Starts a simple SMTP server. Options include:
{host, string()}
the name of the host that the SMTP server shall run on, i.e. the name of this computer.
{port, string()}
the port on the host that shall run the SMTP service, if not 25.
{handler, {module(), function()}}
the handler which is called whenever the server receives a valid
incoming mail message. The specified function (/3
)
is called with the reverse-path (FROM), a list of recipients (RCPT),
and a list of strings (DATA).
server(socket(), Host::string(), Module::atom(), Function::atom()) -> never_returns
Called by server/1
. Should not be called directly by user code.
eol() -> string()
Returns the internet line terminator sequence.
escape(string()) -> string()
Escapes a line per RFC 821, prepending a period if need be.
expect(socket(), integer()) -> ok
Expects a given return-code from the SMTP server. If it does not match what is given, an error is thrown.
get_line(socket()) -> string()
Gets a line of text from the given socket.
get_opt(Options::[option()], Key::atom(), Default::term()) -> term()
Gets an SMTP option. If the specified option in present
in the list, that value is used; if not, the env
key of
ce_smtp.app
is checked, and if no value is found there
the given default is used.
send_line(socket(), string()) -> ok
Sends a line of text to the given socket.