Download the PHP package buildcode/laravel-database-emails without Composer
On this page you can find all versions of the php package buildcode/laravel-database-emails. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download buildcode/laravel-database-emails
More information about buildcode/laravel-database-emails
Files in buildcode/laravel-database-emails
Package laravel-database-emails
Short Description Store and send e-mails using the database
License MIT
Informations about the package laravel-database-emails
Introduction
This package allows you to store and send e-mails using the database.
Requirements
This package requires Laravel 10 or 11.
Installation
Require the package using composer.
Publish the configuration files.
Create the database table required for this package.
Add the e-mail cronjob to your scheduler
Usage
Send an email
E-mails are composed the same way mailables are created.
Sending emails to users in your application
By default, the name
column will be used to set the recipient's name. If you wish to use something different, you should implement the preferredEmailName
method in your model.
By default, the email
column will be used to set the recipient's e-mail address. If you wish to use something different, you should implement the preferredEmailAddress
method in your model.
By default, the app locale will be used. If you wish to use something different, you should implement the preferredEmailLocale
method in your model.
Using mailables
You may also pass a mailable to the e-mail composer.
Attachments
To start attaching files to your e-mails, you may use the attachments
method like you normally would in Laravel.
However, you will have to use this package's Attachment
class.
[!NOTE]
Attachment::fromData()
andAttachment::fromStorage()
are not supported as they work with raw data.
Attaching models to e-mails
You may attach a model to an e-mail. This can be useful to attach a user or another model that belongs to the e-mail.
Scheduling
You may schedule an e-mail by calling later
instead of send
. You must provide a Carbon instance or a strtotime valid date.
Queueing e-mails
[!IMPORTANT] When queueing mail using the
queue
function, it is no longer necessary to schedule theemail:send
command.
If you need more flexibility, you may also pass your own job class:
It could look like this:
Test mode
When enabled, all newly created e-mails will be sent to the specified test e-mail address. This is turned off by default.
E-mails to send per minute
To configure how many e-mails should be sent each command.
Send e-mails immediately
Useful during development when Laravel Scheduler is not running
To enable, set the following environment variable:
Pruning models
By default, e-mails are pruned when they are older than 6 months.
You may change that by adding the following to the AppServiceProvider.php: