Module ce_smtp

Description

Simple SMTP client and server written in Erlang.

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.

Function Index

Exported Functions
client/9Called by send_email/1.
send_email/1Sends an e-mail message to an SMTP server.
server/1Starts a simple SMTP server.
server/4Called by server/1.
Internal Documented Functions
eol/0Returns the internet line terminator sequence.
escape/1Escapes a line per RFC 821, prepending a period if need be.
expect/2Expects a given return-code from the SMTP server.
get_line/1Gets a line of text from the given socket.
get_opt/3Gets an SMTP option.
send_line/2Sends a line of text to the given socket.

Exported Functions

client/9

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/1

send_email([option()]) -> ok | {error, Reason}

Sends an e-mail message to an SMTP server. Options include:

server/1

server([option()]) -> {ok, Pid} | {error, Reason}

Starts a simple SMTP server. Options include:

server/4

server(socket(), Host::string(), Module::atom(), Function::atom()) -> never_returns

Called by server/1. Should not be called directly by user code.

Documented Internal Functions

eol/0

eol() -> string()

Returns the internet line terminator sequence.

escape/1

escape(string()) -> string()

Escapes a line per RFC 821, prepending a period if need be.

expect/2

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/1

get_line(socket()) -> string()

Gets a line of text from the given socket.

get_opt/3

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/2

send_line(socket(), string()) -> ok

Sends a line of text to the given socket.