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