View Source Rambla.Handlers.Smtp (Rambla v1.2.6)
Default handler for SMTP connections. For this handler to work properly, one must configure it with
config :rambla, :smtp,
connections: [
gmail: [
# the smtp relay, e.g. "smtp.gmail.com"
relay: System.get_env("RAMBLA_SMTP_RELAY", "smtp.gmail.com"),
# the username of the smtp relay e.g. "me@gmail.com"
username: System.get_env("RAMBLA_SMTP_USERNAME"),
# the password of the smtp relay e.g. "mypassword"
password: System.get_env("RAMBLA_SMTP_PASSWORD"),
# whether the smtp server needs authentication, valid values are if_available and always,
# Defaults to if_available. If your smtp relay requires authentication set it to always
auth: :always,
# whether to connect on 465 in ssl mode, Defaults to false
ssl: true,
# valid values are always, never, if_available.
# Most modern smtp relays use tls, so set this to always, Defaults to if_available
# tls: :always,
# used in ssl:connect, More info at http://erlang.org/doc/man/ssl.html ,
# Defaults to [{versions , ['tlsv1', 'tlsv1.1', 'tlsv1.2']}],
# This is merged with options listed at: https://github.com/gen-smtp/gen_smtp/blob/master/src/smtp_socket.erl#L46 .
# Any options not present in this list will be ignored.
# tls_options: [versions: [:tlsv1, :"tlsv1.1", :"tlsv1.2"]],
# the hostname to be used by the smtp relay,
# Defaults to: smtp_util:guess_FQDN().
# The hostname on your computer might not be correct, so set this to a valid value.
hostname: System.get_env("RAMBLA_SMTP_HOSTNAME", "gmail.com"),
from: %{"Aleksei Matiushkin" => "matiouchkine@gmail.com"}
]
],
channels: [
chan_3: [connection: :gmail]
]
# Then you can access the connection/channel via `Rambla.Handlers.Smtp` as
Rambla.Handlers.Smtp.publish(:chan_3, "Hi John!\nHow are you?")
Summary
Functions
The list of child_spec
returned
to be embedded into a supervision tree.
An interface to publish messages using the FSM pool.
The entry point: this would start a supervisor with all the pools and stuff
Functions
The list of child_spec
returned
to be embedded into a supervision tree.
Known options:
connection_options
— akeyword()
or a function of arity one, which is to receive channel names and return connection options as a listcount
— the number of workers in the poolchild_opts
— the options to be passed to the worker’s spec (you won’t need those)
Example
Rambla.Handlers.Redis.children_specs(
connection_options: [exchange: "amq.direct"], count: 3)
An interface to publish messages using the FSM pool.
The id
is the specific to an implementation,
for Amqp
it’d be the channel name, for instance.
The second parameter would be a payload, or, if the backend supports it,
the function of arity one, which would receive back the connection pid
.
Example
Rambla.Handlers.Amqp.publish :channel_name, %{foo: :bar}
@spec start_link([ Supervisor.option() | Supervisor.init_option() | {:connection_options, keyword() | (term() -> keyword())} | {:count, non_neg_integer()} ]) :: Supervisor.on_start()
The entry point: this would start a supervisor with all the pools and stuff