GenServer
defmodule EmailSender do
use GenServer
def handle_cast({:send, email}, state) do
# send email
{:noreply, state}
end
end
# Start the server
{:ok, pid} = GenServer.start_link(EmailSender, [])
# This is the client
GenServer.cast(pid, {:send, “
[email protected]"})
#=> :ok