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 another column, you should implement the `preferredEmailName` method in your model.
99
104
100
105
```php
101
106
<?php
102
107
103
-
use Stackkit\LaravelDatabaseEmails\Email;
108
+
use Illuminate\Database\Eloquent\Model;
104
109
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']);
110
+
class User extends Model
111
+
{
112
+
public function preferredEmailName(): string
113
+
{
114
+
return $this->first_name;
115
+
}
116
+
}
110
117
```
111
118
112
-
### Reply-To
119
+
By default, the `email` column will be used to set the recipient's e-mail address. If you wish to use another column, you should implement the `preferredEmailAddress` method in your model.
By default, the app locale will be used to set the recipient's locale. If you wish to use another column, you should implement the `preferredEmailLocale` method in your model.
124
136
125
-
Email::compose()
126
-
->replyTo([
127
-
new Address('john@doe.com', 'John Doe'),
128
-
new Address('jane@doe.com', 'Jane Doe'),
129
-
]);
137
+
```php
138
+
<?php
139
+
140
+
use Illuminate\Database\Eloquent\Model;
141
+
use Illuminate\Contracts\Translation\HasLocalePreference;
142
+
143
+
class User extends Model implements HasLocalePreference
144
+
{
145
+
public function preferredLocale(): string
146
+
{
147
+
return $this->locale;
148
+
}
149
+
}
130
150
```
131
151
132
152
### Using mailables
@@ -145,36 +165,28 @@ Email::compose()
145
165
146
166
### Attachments
147
167
148
-
```php
149
-
<?php
150
-
151
-
use Stackkit\LaravelDatabaseEmails\Email;
152
-
153
-
Email::compose()
154
-
->attach('/path/to/file');
155
-
```
168
+
To start attaching files to your e-mails, you may use the `attach` method like you normally would in Laravel.
169
+
However, you will have to use this package's `Attachment` class.
156
170
157
-
Or for in-memory attachments:
158
171
159
172
```php
160
173
<?php
161
174
162
175
use Stackkit\LaravelDatabaseEmails\Email;
176
+
use Stackkit\LaravelDatabaseEmails\Attachment;
163
177
164
178
Email::compose()
165
-
->attachData('<p>Your order has shipped!</p>', 'order.html');
Note: `fromData()` and `fromStorage()` are not supported as the work with raw data.
189
+
</small>
178
190
179
191
### Scheduling
180
192
@@ -189,27 +201,6 @@ Email::compose()
189
201
->later('+2 hours');
190
202
```
191
203
192
-
### Encryption (Optional)
193
-
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.
195
-
196
-
```text
197
-
Without encryption
198
-
199
-
7 bytes (label)
200
-
16 bytes (recipient)
201
-
20 bytes (subject)
202
-
48 bytes (view name)
203
-
116 bytes (variables)
204
-
1874 bytes (e-mail content)
205
-
4 bytes (attempts, sending, failed, encrypted)
206
-
57 bytes (created_at, updated_at, deleted_at)
207
-
... x 10.000 rows = ± 21.55 MB
208
-
209
-
With encryption the table size is ± 50.58 MB.
210
-
```
211
-
212
-
213
204
### Queueing e-mails
214
205
215
206
**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`.
@@ -235,22 +226,41 @@ Email::compose()
235
226
->queue(null, null, now()->addMinutes(10));
236
227
```
237
228
238
-
### Test mode (Optional)
229
+
If you need more flexibility over how to queued mails are retried, please implement your own email job.
230
+
231
+
Within the job you can send the mail like this:
232
+
233
+
```php
234
+
use Stackkit\LaravelDatabaseEmails\Sender;
235
+
236
+
(new Sender)->send($email);
237
+
```
238
+
239
+
### Test mode
239
240
240
241
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