Send defaults
The send defaults are typed option classes from options-for-laravel, in RoundlyConsulting\Campaigns\Options. Each falls back to its config/campaigns.php value until an option is stored — then the stored value wins, without a deploy:
use RoundlyConsulting\Campaigns\Facades\Campaigns;
use RoundlyConsulting\Campaigns\Options\DefaultFromAddress;
use RoundlyConsulting\Campaigns\Options\DefaultFromName;
use RoundlyConsulting\Campaigns\Options\OnlyVerifiedRecipients;
use RoundlyConsulting\Options\Facades\Options;
Options::set(DefaultFromAddress::class, '[email protected]');
Options::set(DefaultFromName::class, 'Example Shop');
Options::set(OnlyVerifiedRecipients::class, true);
// A from-less campaign now sends from [email protected], and to($user)
// skips unverified contacts by default.
Campaigns::create('Spring sale', '<p>The spring sale starts today.</p>')->to($user)->dispatch();The options
| Option class | Registry key | Config seed | Type |
|---|---|---|---|
DefaultFromName | campaigns.from-name | from-name | string |
DefaultFromAddress | campaigns.from-address | from-address | string |
DefaultChannel | campaigns.channel | notification-channel | string |
DefaultSendingQueue | campaigns.sending-queue | sending-queue | string |
OnlyVerifiedRecipients | campaigns.only-verified-recipients | recipients.only-verified | boolean |
DefaultRecipientContactType | campaigns.recipient-contact-type | recipients.contact-type | ContactType |
The keys are registered with the options registry at boot, so you can address an option by key as well as by class:
Options::get('campaigns.from-address'); // by registered key — same as DefaultFromAddress::class
Options::forget(DefaultFromAddress::class); // drop the stored value, back to config('campaigns.from-address')Precedence
- Explicit builder calls — ->from(), ->onlyVerified(), ->viaContactType() — always win.
- Then the stored option.
- Then the config value and its env variable.
Campaigns::settings() returns the values in effect right now — fromName(), fromAddress(), notificationChannel(), sendingQueue(), onlyVerifiedRecipients() and defaultRecipientContactType().
store, process-recipient-job and notification are config-only — they pick classes rather than send defaults. An invalid recipients.contact-type value throws InvalidConfigurationException — it no longer reads as email.
Show your open-source love
This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.
More ways to support, including cryptoBy donating, you agree to our donation terms.
Want this built into your product?
We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.