Skip to content

Commit d244293

Browse files
committed
wording and readme update
1 parent 1bfd1b3 commit d244293

File tree

4 files changed

+98
-61
lines changed

4 files changed

+98
-61
lines changed

README.md

Lines changed: 83 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,28 @@
1010
## Introduction
1111

1212
This is a package that stores and queues e-mails using a database table. Easily send e-mails using a cronjob and schedule e-mails that should be sent at a specific date and time.
13-
## Installation
13+
14+
## Table Of Contents
15+
16+
- [Installation](#installation)
17+
- [Usage](#usage)
18+
- [Send an e-mail](#send-an-email)
19+
- [Specify multiple recipients](#specify-multiple-recipients)
20+
- [CC and BCC](#cc-and-bcc)
21+
- [Mailables](#using-mailables)
22+
- [Attachments](#attachments)
23+
- [Custom sender](#custom-sender)
24+
- [Scheduling](#scheduling)
25+
- [Resend failed e-mails](#resend-failed-e-mails)
26+
- [Encryption (optional)](#encryption-(optional))
27+
- [Test mode (optional)](#test-mode-(optional))
28+
29+
### Installation
1430

1531
First, require the package using composer.
1632

1733
```bash
18-
$ composer require buildcode/laravel-database-emails
34+
composer require buildcode/laravel-database-emails
1935
```
2036

2137
If you're running Laravel 5.5 or later you may skip this step. Add the service provider to your application.
@@ -27,13 +43,13 @@ Buildcode\LaravelDatabaseEmails\LaravelDatabaseEmailsServiceProvider::class,
2743
Publish the configuration files.
2844

2945
```bash
30-
$ php artisan vendor:publish --provider=Buildcode\\LaravelDatabaseEmails\\LaravelDatabaseEmailsServiceProvider
46+
php artisan vendor:publish --provider=Buildcode\\LaravelDatabaseEmails\\LaravelDatabaseEmailsServiceProvider
3147
```
3248

3349
Create the database table required for this package.
3450

3551
```bash
36-
$ php artisan migrate
52+
php artisan migrate
3753
```
3854

3955
Now add the e-mail cronjob to your scheduler.
@@ -47,17 +63,19 @@ Now add the e-mail cronjob to your scheduler.
4763
*/
4864
protected function schedule(Schedule $schedule)
4965
{
50-
$schedule->command('email:send')->everyMinute();
66+
$schedule->command('email:send')->everyMinute()->withoutOverlapping(5);
5167
}
5268
```
5369

54-
## Usage
70+
### Usage
5571

56-
### Create An Email
72+
#### Send an email
5773

5874
```php
75+
use Buildcode\LaravelDatabaseEmails\Email;
76+
5977
Email::compose()
60-
->label('welcome-mail-1.0')
78+
->label('welcome')
6179
->recipient('[email protected]')
6280
->subject('This is a test')
6381
->view('emails.welcome')
@@ -67,90 +85,114 @@ Email::compose()
6785
->send();
6886
```
6987

70-
### Specify Recipients
88+
#### Specify multiple recipients
7189

7290
```php
73-
74-
91+
use Buildcode\LaravelDatabaseEmails\Email;
92+
93+
Buildcode\LaravelDatabaseEmails\Email::compose()
94+
->recipient([
95+
96+
97+
]);
98+
```
7599

76-
Email::compose()->recipient($one);
77-
Email::compose()->recipient($multiple);
100+
#### CC and BCC
78101

79-
Email::compose()->cc($one);
80-
Email::compose()->cc($multiple);
102+
```php
103+
use Buildcode\LaravelDatabaseEmails\Email;
81104

82-
Email::compose()->bcc($one);
83-
Email::compose()->bcc($multiple);
105+
Email::compose()
106+
107+
108+
109+
84110
```
85111

86-
### Mailables
112+
#### Using mailables
87113

88114
You may also pass a mailable to the e-mail composer.
89115

90116
```php
117+
use Buildcode\LaravelDatabaseEmails\Email;
118+
91119
Email::compose()
92120
->mailable(new OrderShipped())
93121
->send();
94122
```
95123

96-
### Attachments
124+
#### Attachments
97125

98126
```php
127+
use Buildcode\LaravelDatabaseEmails\Email;
128+
99129
Email::compose()
100130
->attach('/path/to/file');
101131
```
102132

103-
Or for in-memory attachments...
133+
Or for in-memory attachments:
104134

105135
```php
136+
use Buildcode\LaravelDatabaseEmails\Email;
137+
106138
Email::compose()
107139
->attachData('<p>Your order has shipped!</p>', 'order.html');
108140
```
109141

110-
### Custom Sender
142+
#### Custom Sender
111143

112144
```php
145+
use Buildcode\LaravelDatabaseEmails\Email;
146+
113147
Email::compose()
114148
->from('[email protected]', 'John Doe');
115149
```
116150

117-
### Schedule An Email
151+
#### Scheduling
118152

119-
You may schedule an e-mail by calling `later` instead of `send` at the end of the chain. You must provide a Carbon instance or a strtotime valid date.
153+
You may schedule an e-mail by calling `later` instead of `send`. You must provide a Carbon instance or a strtotime valid date.
120154

121155
```php
156+
use Buildcode\LaravelDatabaseEmails\Email;
157+
122158
Email::compose()
123159
->later('+2 hours');
124160
```
125161

126-
### Manually Sending E-mails
162+
#### Resend failed e-mails
127163

128-
If you're not running the cronjob and wish to send the queued e-mails, you can run the `email:send` command.
164+
##### Resend all failed e-mails
129165

130166
```bash
131-
$ php artisan email:send
167+
php artisan email:retry
132168
```
133169

134-
### Failed E-mails
135-
136-
By default, we will attempt to send an e-mail 3 times if it fails. If it still fails the 3rd time, it will permanently be marked as failed. You can change the number of times an e-mail should be attempted to be sent using the `retry.attempts` configuration.
137-
138-
### Retry sending failed e-mails
139-
140-
If you wish to retry sending failed e-mails, you may call the `email:retry` command. The command will grab any failed e-mail and push it onto the queue. You may also provide the id of a specific e-mail.
170+
##### Resend a specific failed e-mail
141171

142172
```bash
143-
$ php artisan email:retry
144-
# or...
145-
$ php artisan email:retry 1
173+
php artisan email:retry 1
146174
```
147175

148-
### Encryption
176+
#### Encryption (Optional)
177+
178+
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. Please note that by encrypting the e-mail it takes more disk space.
149179

150-
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. Please note that encrypting the e-mail body takes a lot of disk space.
180+
```text
181+
Without encryption
151182
152-
### Testing Address
183+
7 bytes (label)
184+
16 bytes (recipient)
185+
20 bytes (subject)
186+
48 bytes (view name)
187+
116 bytes (variables)
188+
1874 bytes (e-mail content)
189+
4 bytes (attempts, sending, failed, encrypted)
190+
57 bytes (created_at, updated_at, deleted_at)
191+
... x 10.000 rows = ± 21.55 MB
192+
193+
With encryption the table size is ± 50.58 MB.
194+
```
153195

154-
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 off by default.
196+
#### Test mode (Optional)
155197

156-
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.
198+
When enabled, all newly created e-mails will be sent to the specified test e-mail address. This is turned off by default.

config/laravel-database-emails.php

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,24 @@
44

55
/*
66
|--------------------------------------------------------------------------
7-
| Retry Mode
7+
| Attempts
88
|--------------------------------------------------------------------------
99
|
10-
| Here you may specify the number of attempts the cronjob should get
11-
| to send an email. If the sending fails after the number of max
12-
| tries, we will no longer attempt to send that e-mail.
10+
| Here you may specify the number of times the cronjob will try to send an e-mail.
11+
| Once the max attempt count is reached, the e-mail will be marked as failed
12+
| and will no longer be sent.
1313
|
1414
*/
1515

16-
'retry' => [
17-
18-
'attempts' => 3,
19-
20-
],
16+
'attempts' => 3,
2117

2218
/*
2319
|--------------------------------------------------------------------------
2420
| Encryption
2521
|--------------------------------------------------------------------------
2622
|
27-
| Here you may enable encryption for all e-mails. If enabled, we
28-
| will automatically encrypt all the view data, recipient and
29-
| decrypt it during the sending phase.
23+
| Here you may enable encryption for all e-mails. The e-mail will be encrypted according
24+
| your application's configuration (OpenSSL AES-256-CBC by default).
3025
|
3126
*/
3227

@@ -37,9 +32,9 @@
3732
| Test E-mail
3833
|--------------------------------------------------------------------------
3934
|
40-
| When developing the application or testing on a staging server you may
41-
| wish to send all e-mails to a specific test inbox. If enabled, all
42-
| recpient emails will be hijacked and sent to the test address.
35+
| When developing your application or testing on a staging server you may
36+
| wish to send all e-mails to a specific test inbox. Once enabled, every
37+
| newly created e-mail will be sent to the specified test address.
4338
|
4439
*/
4540

@@ -60,9 +55,9 @@
6055
| Cronjob Limit
6156
|--------------------------------------------------------------------------
6257
|
63-
| Limit the number of e-mails the cronjob may send at a time. This is useful
64-
| if you want to prevent overlapping cronjobs. Keep in mind we already
65-
| handle overlapping gracefully, however setting a limit is adviced.
58+
| Limit the number of e-mails that should be sent at a time. Please ajust this
59+
| configuration based on the number of e-mails you expect to send and
60+
| the throughput of your e-mail sending provider.
6661
|
6762
*/
6863

src/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Config
1111
*/
1212
public static function maxAttemptCount()
1313
{
14-
return max(config('laravel-database-emails.retry.attempts', 1), 3);
14+
return max(config('laravel-database-emails.attempts', 1), 3);
1515
}
1616

1717
/**

tests/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ protected function getPackageProviders($app)
7878
*/
7979
protected function getEnvironmentSetUp($app)
8080
{
81-
$app['config']->set('laravel-database-emails.retry.attempts', 3);
81+
$app['config']->set('laravel-database-emails.attempts', 3);
8282

8383
$app['config']->set('database.default', 'testbench');
8484
$app['config']->set('database.connections.testbench', [

0 commit comments

Comments
 (0)