Skip to main content

Crate laravel_mailing_list

Crate laravel_mailing_list 

Source
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 local driver write them.
templates
The template types the package gives laravel-template-engine (feature template-engine).
transfer
Moving subscribers in and out of a local list as CSV.

Structs§

CampaignDraft
A campaign being written: list.campaign("Subject").markdown(body).create().
CampaignMail
One subscriber’s copy of a campaign. Its frame is the view mailing-list::mail.campaign; override it in resources/views/vendor/mailing-list/mail/campaign.html.
ConfirmSubscription
The email with the link that confirms a subscription. Its view is mailing-list::mail.confirm; override it in resources/views/vendor/mailing-list/mail/confirm.html.
Email
An email address, trimmed and lowercased once, so every list, driver and unique key agrees on what “the same address” means.
MailingListConfig
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:
MailingListServiceProvider
Adds the package’s settings, tables, pages and emails, and the lists you declare.
PrepareCampaign
Writes a delivery row for every confirmed subscriber and queues the jobs that mail them. Running it again changes nothing that is already written.
SendDeliveries
Mails one page of a campaign’s subscribers.
Stats
How many deliveries of a campaign are in each state.
SubscribeForm
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 the mailing_list_status flash 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.