A full stack package to add mailing functionality to Laravel applications. This package allows you to associate recipients (contacts) to your mailable files.
- Require using composer:
composer require dainsys/mailing
. - You can install all package assets by running
php artisan mailing:install
command.- Another option is installing each asset individually:
- Publish the assets:
@php artisan vendor:publish --force --tag=mailing:assets
.- optionally, you add the following line to your
composer
file, under thescripts
andpost-update-cmd
key, to publish the assets every time you update your composer dependencies:@php artisan vendor:publish --tag=mailing:assets --force --ansi
.
- optionally, you add the following line to your
- Publish the assets:
- If you may want to customize the migrations before next step, first publish them:
@php artisan vendor:publish --force --tag=mailing:migrations
. - Run the migrations:
php artisan migrate
.
- Another option is installing each asset individually:
- Only super admin users are allowed to interact with the app. You can register them using any of the following options:
- Using the register method of your
AuthServiceProvider
:\Dainsys\Mailing\Mailing::registerSuperUsers(["super@user1.com", "super@user2.com"]);
. - In your
.env
file,MAILING_SUPER_USERS='super@user1.com,super@user2.com'
- Using the register method of your
- Visit package main route:
/dainsys/mailing/about
. - Optionally, you may want to publish and tweek the config file:
@php artisan vendor:publish --force --tag=mailing:config
. - This package has its own views, designed with livewire and AdminLte. However, if you may want to change them then you can publish them with
@php artisan vendor:publish --force --tag=mailing:views
. - Package views extend it's own layout app. However, you can change this by adding the key
MAILING_LAYOUT_VIEW
to your.env
file. Or, change it directly in themailing
config file, under thelayout
key.
- The package is configured to auto discover your mailables within then
app\Mail
directory. However, if your mailables reside outside this folder or if you want to register another directory, add the line\Dainsys\Mailing\Mailing::bind(app_path('Mail'));
to yourAppServiceProvider
. The package will try to load all your mailables for all directories added. - Visit route
/mailing/admin/recipients
to manage your recipients contacts. - Visit route
/mailing/admin/mailables
to manage your mailables and assign them to the recipients. - In your mailables, you can access the array of recipients associated to that class with the code snippet
\Dainsys\Mailing\Mailing::recipients($this);
. For example,->to(\Dainsys\Mailing\Mailing::recipients($this))