Expand description
Mailing lists for Laravel Rust: double opt-in subscriptions with a consent record, one-click unsubscribe, and a suppression list, kept in your own database.
Declare your lists in src/app.rs and run laravel migrate:
use laravel::Application;
use laravel_mailing_list::{List, MailingListServiceProvider};
Application::configure().with_providers(|providers| {
providers.add(MailingListServiceProvider::new().list("blog", List::local().name("AxVi blog")));
})Then a form that posts email to /mailing-list/blog/subscribe starts a subscription, and
code does the same with lists::get:
use laravel_mailing_list::{Subscription, lists};
let blog = lists::get("blog").await?;
blog.subscribe(Subscription::new("ann@example.com").name("Ann").source("footer")).await?;Re-exports§
pub use crate::lists::Driver;pub use crate::lists::List;pub use crate::lists::ListConfig;pub use crate::lists::ListHandle;pub use crate::lists::Subscribed;pub use crate::lists::Subscription;
Modules§
- events
- What the package dispatches. Listen to these to keep another system in step, such as a CRM, or to count sign-ups.
- lists
- The lists an application declares, and what you do with them.
- models
- The package’s tables, as Laravel Rust models. Only lists with the
localdriver write them. - templates
- The template types the package gives laravel-template-engine (feature
template-engine). - transfer
- Moving subscribers in and out of a
locallist as CSV.
Structs§
- Campaign
Draft - A campaign being written:
list.campaign("Subject").markdown(body).create(). - Campaign
Mail - One subscriber’s copy of a campaign. Its frame is the view
mailing-list::mail.campaign; override it inresources/views/vendor/mailing-list/mail/campaign.html. - Confirm
Subscription - The email with the link that confirms a subscription. Its view is
mailing-list::mail.confirm; override it inresources/views/vendor/mailing-list/mail/confirm.html. - An email address, trimmed and lowercased once, so every list, driver and unique key agrees on what “the same address” means.
- Mailing
List Config - The package’s settings, read from the environment. Every one has a default, so nothing needs
to be set. An application changes them in
with_config: - Mailing
List Service Provider - Adds the package’s settings, tables, pages and emails, and the lists you declare.
- Prepare
Campaign - Writes a delivery row for every confirmed subscriber and queues the jobs that mail them. Running it again changes nothing that is already written.
- Send
Deliveries - Mails one page of a campaign’s subscribers.
- Stats
- How many deliveries of a campaign are in each state.
- Subscribe
Form - What a subscribe form sends.
Functions§
- confirm
GET /{prefix}/confirm/{subscriber}, signed and temporary: confirms the subscription.- subscribe
POST /{prefix}/{list}/subscribe: starts a subscription. Answers JSON to clients that want it, an HTML fragment to htmx, and a redirect back with themailing_list_statusflash to the rest.- unsubscribe
POST /{prefix}/unsubscribe/{subscriber}, signed: unsubscribes. Gmail’s and Yahoo’s “Unsubscribe” button lands here too.- unsubscribe_
page GET /{prefix}/unsubscribe/{subscriber}, signed: asks before unsubscribing, because mail scanners open the links in emails and must not unsubscribe anyone.