Skip to content

Commit 33a7d3a

Browse files
committed
Move readme back into repository
1 parent 533bd9a commit 33a7d3a

File tree

1 file changed

+188
-3
lines changed

1 file changed

+188
-3
lines changed

README.md

Lines changed: 188 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,193 @@
77
<a href="https://packagist.org/packages/buildcode/laravel-database-emails"><img src="https://poser.pugx.org/buildcode/laravel-database-emails/license.svg" alt="License"></a>
88
</p>
99

10-
## Introduction
10+
# Package Documentation
1111

12-
This package allows you to easily send e-mails using a database table.
12+
This package allows you to store and send e-mails using a database.
1313

14-
Official documentation, changelog and more [is located here](https://stackkit.github.io/laravel-database-emails/).
14+
## Contribution
15+
16+
The package is MIT licenced, meaning it's open source and you are free to copy or fork it and modify it any way you wish.
17+
18+
We feel the package is currently feature complete, but feel free to send a pull request or help improve existing code.
19+
20+
21+
# Installation
22+
23+
Require the package using composer.
24+
25+
```bash
26+
composer require stackkit/laravel-database-emails
27+
```
28+
29+
If you're running Laravel 5.5 or later you may skip this step. Add the service provider to your application.
30+
31+
```
32+
Stackkit\LaravelDatabaseEmails\LaravelDatabaseEmailsServiceProvider::class,
33+
```
34+
35+
Publish the configuration files.
36+
37+
```bash
38+
php artisan vendor:publish --provider=Stackkit\\LaravelDatabaseEmails\\LaravelDatabaseEmailsServiceProvider
39+
```
40+
41+
Create the database table required for this package.
42+
43+
```bash
44+
php artisan migrate
45+
```
46+
47+
Add the e-mail cronjob to your scheduler
48+
49+
```php
50+
<?php
51+
52+
/**
53+
* Define the application's command schedule.
54+
*
55+
* @param \Illuminate\Console\Scheduling\Schedule $schedule
56+
* @return void
57+
*/
58+
protected function schedule(Schedule $schedule)
59+
{
60+
$schedule->command('email:send')->everyMinute()->withoutOverlapping(5);
61+
}
62+
```
63+
64+
65+
# Usage
66+
67+
### Send an email
68+
69+
```php
70+
<?php
71+
72+
use Stackkit\LaravelDatabaseEmails\Email;
73+
74+
Email::compose()
75+
->label('welcome')
76+
->recipient('[email protected]')
77+
->subject('This is a test')
78+
->view('emails.welcome')
79+
->variables([
80+
'name' => 'John Doe',
81+
])
82+
->send();
83+
```
84+
85+
### Specify multiple recipients
86+
87+
```php
88+
<?php
89+
90+
use Stackkit\LaravelDatabaseEmails\Email;
91+
92+
Email::compose()
93+
->recipient([
94+
95+
96+
]);
97+
```
98+
99+
### CC and BCC
100+
101+
```php
102+
<?php
103+
104+
use Stackkit\LaravelDatabaseEmails\Email;
105+
106+
Email::compose()
107+
108+
109+
110+
111+
```
112+
113+
### Using mailables
114+
115+
You may also pass a mailable to the e-mail composer.
116+
117+
```php
118+
<?php
119+
120+
use Stackkit\LaravelDatabaseEmails\Email;
121+
122+
Email::compose()
123+
->mailable(new OrderShipped())
124+
->send();
125+
```
126+
127+
### Attachments
128+
129+
```php
130+
<?php
131+
132+
use Stackkit\LaravelDatabaseEmails\Email;
133+
134+
Email::compose()
135+
->attach('/path/to/file');
136+
```
137+
138+
Or for in-memory attachments:
139+
140+
```php
141+
<?php
142+
143+
use Stackkit\LaravelDatabaseEmails\Email;
144+
145+
Email::compose()
146+
->attachData('<p>Your order has shipped!</p>', 'order.html');
147+
```
148+
149+
### Custom Sender
150+
151+
```php
152+
<?php
153+
154+
use Stackkit\LaravelDatabaseEmails\Email;
155+
156+
Email::compose()
157+
->from('[email protected]', 'John Doe');
158+
```
159+
160+
### Scheduling
161+
162+
You may schedule an e-mail by calling `later` instead of `send`. You must provide a Carbon instance or a strtotime valid date.
163+
164+
```php
165+
<?php
166+
167+
use Stackkit\LaravelDatabaseEmails\Email;
168+
169+
Email::compose()
170+
->later('+2 hours');
171+
```
172+
173+
### Encryption (Optional)
174+
175+
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.
176+
177+
```text
178+
Without encryption
179+
180+
7 bytes (label)
181+
16 bytes (recipient)
182+
20 bytes (subject)
183+
48 bytes (view name)
184+
116 bytes (variables)
185+
1874 bytes (e-mail content)
186+
4 bytes (attempts, sending, failed, encrypted)
187+
57 bytes (created_at, updated_at, deleted_at)
188+
... x 10.000 rows = ± 21.55 MB
189+
190+
With encryption the table size is ± 50.58 MB.
191+
```
192+
193+
### Test mode (Optional)
194+
195+
When enabled, all newly created e-mails will be sent to the specified test e-mail address. This is turned off by default.
196+
197+
### E-mails to send per minute
198+
199+
To configure how many e-mails should be sent each command, please check the `limit` option. The default is `20` e-mails every command.

0 commit comments

Comments
 (0)