You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
99
84
100
85
```php
101
-
<?php
102
-
103
-
use Stackkit\LaravelDatabaseEmails\Email;
104
-
105
-
Email::compose()
106
-
->cc('john@doe.com')
107
-
->cc(['john@doe.com', 'jane@doe.com'])
108
-
->bcc('john@doe.com')
109
-
->bcc(['john@doe.com', 'jane@doe.com']);
86
+
class User extends Model
87
+
{
88
+
public function preferredEmailName(): string
89
+
{
90
+
return $this->first_name;
91
+
}
92
+
}
110
93
```
111
94
112
-
### Reply-To
95
+
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.
> `Attachment::fromData()` and `Attachment::fromStorage()` are not supported as they work with raw data.
169
147
170
-
```php
171
-
<?php
148
+
### Attaching models to e-mails
172
149
173
-
use Stackkit\LaravelDatabaseEmails\Email;
150
+
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.
174
151
152
+
```php
175
153
Email::compose()
176
-
->from('john@doe.com', 'John Doe');
154
+
->model(User::find(1));
177
155
```
178
156
179
157
### Scheduling
180
158
181
159
You may schedule an e-mail by calling `later` instead of `send`. You must provide a Carbon instance or a strtotime valid date.
182
160
183
161
```php
184
-
<?php
185
-
186
-
use Stackkit\LaravelDatabaseEmails\Email;
187
-
188
162
Email::compose()
189
163
->later('+2 hours');
190
164
```
191
165
192
-
### Encryption (Optional)
166
+
### Queueing e-mails
167
+
168
+
> [!IMPORTANT]
169
+
> When queueing mail using the `queue` function, it is no longer necessary to schedule the `email:send` command.
193
170
194
-
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.
**Important**: When queueing mail using the `queue` function, it is no longer necessary to schedule the `email:send` command. Please make sure it is removed from `app/Console/Kernel.php`.
190
+
It could look like this:
216
191
217
192
```php
218
193
<?php
219
194
220
-
use Stackkit\LaravelDatabaseEmails\Email;
221
-
222
-
Email::compose()
223
-
->queue();
224
-
225
-
// on a specific connection
226
-
Email::compose()
227
-
->queue('sqs');
195
+
namespace App\Jobs;
228
196
229
-
// on a specific queue
230
-
Email::compose()
231
-
->queue(null, 'email-queue');
197
+
use Illuminate\Contracts\Queue\ShouldQueue;
198
+
use Stackkit\LaravelDatabaseEmails\SendEmailJob;
232
199
233
-
// timeout (send mail in 10 minutes)
234
-
Email::compose()
235
-
->queue(null, null, now()->addMinutes(10));
200
+
class CustomSendEmailJob extends SendEmailJob implements ShouldQueue
201
+
{
202
+
// Define custom retries, backoff, etc...
203
+
}
236
204
```
237
205
238
-
### Test mode (Optional)
206
+
### Test mode
239
207
240
208
When enabled, all newly created e-mails will be sent to the specified test e-mail address. This is turned off by default.
0 commit comments