Skip to content

Commit e4e5ecc

Browse files
Create README.md
1 parent 0e0fd11 commit e4e5ecc

File tree

1 file changed

+116
-0
lines changed

1 file changed

+116
-0
lines changed

README.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
<p align="center">
2+
<img src="/logo.png">
3+
</p>
4+
5+
## Introduction
6+
7+
This is a package that stores and queues e-mails using a database table. Easily send e-mails using a cronjob or schedule e-mails that should be sent at a specific date and time.
8+
## Installation
9+
10+
First, require the package using composer.
11+
12+
```bash
13+
$ composer require buildcode/laravel-database-emails
14+
```
15+
16+
If you're running Laravel 5.5 or later you may skip this step. Add the service provider to your application.
17+
18+
```php
19+
Buildcode\LaravelGhost\LaravelDatabaseEmailsServiceProvider::class,
20+
```
21+
22+
Publish the configuration file.
23+
24+
```bash
25+
$ php artisan vendor:publish --provider=Buildcode\\LaravelGhost\\LaravelDatabaseEmailsServiceProvider
26+
```
27+
28+
Create the e-mails database table migration.
29+
30+
```bash
31+
$ php artisan email:table
32+
$ php artisan migrate
33+
```
34+
35+
Now add the e-mail cronjob to your scheduler.
36+
37+
```php
38+
/**
39+
* Define the application's command schedule.
40+
*
41+
* @param \Illuminate\Console\Scheduling\Schedule $schedule
42+
* @return void
43+
*/
44+
protected function schedule(Schedule $schedule)
45+
{
46+
$schedule->command('email:send')->everyMinute();
47+
}
48+
```
49+
50+
## Usage
51+
52+
### Create An Email
53+
54+
```php
55+
Buildcode\LaravelDatabaseEmails\Email::compose()
56+
->label('welcome-mail-1.0')
57+
->recipient('[email protected]')
58+
->subject('This is a test')
59+
->view('emails.welcome')
60+
->variables([
61+
'name' => 'John Doe',
62+
])
63+
->send();
64+
```
65+
66+
### Schedule An Email
67+
68+
You may schedule an e-mail by calling `schedule` instead of `send` at the end of the chain. You must provide a Carbon instance or a strtotime valid date.
69+
70+
```php
71+
Buildcode\LaravelDatabaseEmails\Email::compose()
72+
->label('welcome-mail-1.0')
73+
->recipient('[email protected]')
74+
->subject('This is a test')
75+
->view('emails.welcome')
76+
->variables([
77+
'name' => 'John Doe',
78+
])
79+
->schedule('+2 hours');
80+
```
81+
82+
### Manually Sending E-mails
83+
84+
If you're not running the cronjob and wish to send the queued e-mails, you can run the `email:send` command.
85+
86+
```bash
87+
$ php artisan email:send
88+
```
89+
90+
### Failed E-mails
91+
92+
By default, we will attempt to send an e-mail 3 times if it somehow fails.
93+
94+
### Retry sending failed e-mails
95+
96+
If you wish to reset failed e-mails and attempt to send them again, you may call the `email:failed` command. The command will grab any failed e-mail and push it onto the queue.
97+
98+
```bash
99+
$ php artisan email:failed
100+
```
101+
102+
### Encryption
103+
104+
If you wish to encrypt your e-mails, please enable the `encrypt` option in the configuration file. This is disabled by default. Encryption and decryption will be handled by Laravel's built-in encryption mechanism.
105+
106+
### Testing Address
107+
108+
If you wish to send e-mails to a test address but don't necessarily want to use a service like mailtrap, please take a look at the `testing` configuration. This is turned on by default.
109+
110+
During the creation of an e-mail, the recipient will be replaced by the test e-mail. This is useful for local development or testing on a staging server.
111+
112+
## Todo
113+
114+
- Add support for CC, BCC and attachments
115+
- Add support for Mailables
116+
- Add tests

0 commit comments

Comments
 (0)