Swoosh v0.4.0 Swoosh.Adapters.Local.Storage.Memory
In-memory storage driver used by the Swoosh.Adapters.Local module.
The emails in this mailbox are stored in memory and won’t persist once your application is stopped.
Summary
Functions
List all the emails in the mailbox
Delete all the emails currently in the mailbox
Get a specific email from the mailbox
Pop the last email from the mailbox
Push a new email into the mailbox
Starts the server
Stops the server
Functions
List all the emails in the mailbox.
Examples
iex> email = new |> from("tony@stark.com")
%Swoosh.Email{from: {"", "tony@stark.com"}, [...]}
iex> Memory.push(email)
%Swoosh.Email{from: {"", "tony@stark.com"}, headers: %{"Message-ID": "a1b2c3"}, [...]}
iex> Memory.all()
[%Swoosh.Email{from: {"", "tony@stark.com"}, headers: %{"Message-ID": "a1b2c3"}, [...]}]
Delete all the emails currently in the mailbox.
Examples
iex> email = new |> from("tony@stark.com")
%Swoosh.Email{from: {"", "tony@stark.com"}, [...]}
iex> Memory.push(email)
%Swoosh.Email{from: {"", "tony@stark.com"}, headers: %{"Message-ID": "a1b2c3"}, [...]}
iex> Memory.delete_all()
:ok
iex> Memory.list()
[]
Get a specific email from the mailbox.
Examples
iex> email = new |> from("tony@stark.com")
%Swoosh.Email{from: {"", "tony@stark.com"}, [...]}
iex> Memory.push(email)
%Swoosh.Email{from: {"", "tony@stark.com"}, headers: %{"Message-ID": "a1b2c3"}, [...]}
iex> Memory.get("A1B2C3")
%Swoosh.Email{from: {"", "tony@stark.com"}, headers: %{"Message-ID": "a1b2c3"}, [...]}
Pop the last email from the mailbox.
Examples
iex> email = new |> from("tony@stark.com")
%Swoosh.Email{from: {"", "tony@stark.com"}, [...]}
iex> Memory.push(email)
%Swoosh.Email{from: {"", "tony@stark.com"}, headers: %{"Message-ID": "a1b2c3"}, [...]}
iex> Memory.all() |> Enum.count()
1
iex> Memory.pop()
%Swoosh.Email{from: {"", "tony@stark.com"}, headers: %{"Message-ID": "a1b2c3"}, [...]}
iex> Memory.all() |> Enun.count()
0
Push a new email into the mailbox.
In order to make it easy to fetch a single email, a Message-ID
header is
added to the email before being stored.
Examples
iex> email = new |> from("tony@stark.com")
%Swoosh.Email{from: {"", "tony@stark.com"}, [...]}
iex> Memory.push(email)
%Swoosh.Email{from: {"", "tony@stark.com"}, headers: %{"Message-ID": "a1b2c3"}, [...]}