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
html: '<p>Attached is the document you requested.</p>',
265
+
attachments: [
266
+
{
267
+
filename: mediaDoc.filename,
268
+
content: buffer,
269
+
contentType: mediaDoc.mimeType,
270
+
},
271
+
],
272
+
})
273
+
```
274
+
275
+
### With Resend adapter:
276
+
277
+
```ts
278
+
const mediaDoc =awaitpayload.findByID({
279
+
collection: 'media',
280
+
id: 'your-file-id',
281
+
})
282
+
283
+
// If using cloud storage, Resend can fetch from the URL directly
284
+
awaitpayload.sendEmail({
285
+
to: 'user@example.com',
286
+
subject: 'Your document',
287
+
html: '<p>Attached is the document you requested.</p>',
288
+
attachments: [
289
+
{
290
+
filename: mediaDoc.filename,
291
+
path: mediaDoc.url, // Resend will fetch from this URL
292
+
},
293
+
],
294
+
})
295
+
296
+
// For local storage, read the file and convert to Base64
297
+
import { readFile } from'node:fs/promises'
298
+
const fileBuffer =awaitreadFile(mediaDoc.url)
299
+
300
+
awaitpayload.sendEmail({
301
+
to: 'user@example.com',
302
+
subject: 'Your document',
303
+
html: '<p>Attached is the document you requested.</p>',
304
+
attachments: [
305
+
{
306
+
filename: mediaDoc.filename,
307
+
content: fileBuffer.toString('base64'),
308
+
},
309
+
],
310
+
})
311
+
```
312
+
161
313
## Using multiple mail providers
162
314
163
315
Payload supports the use of a single transporter of email, but there is nothing stopping you from having more. Consider a use case where sending bulk email is handled differently than transactional email and could be done using a [hook](/docs/hooks/overview).
0 commit comments