payloadcms / payload

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
https://payloadcms.com
MIT License
23.08k stars 1.43k forks source link

sendMail error handling #5328

Open jaanuspoldre opened 5 months ago

jaanuspoldre commented 5 months ago

Link to reproduction

No response

Describe the Bug

payload.sendMail function should throw error instead of returning the error. Or is there a specific reason for this?

https://github.com/payloadcms/payload/blob/0eb7b44735b8385ae5256fcf3b538fae0a11b84d/packages/payload/src/email/sendEmail.ts#L11

To Reproduce

  1. Setup payload email with eg. smtp and bad credentials:
await payload.init({
    ...,
    email: {
        transportOptions: {
            host: 'yourhost',
            secure: true,
            port: ...,
            auth: {
                user: 'blabla',
                pass: 'passbla',
            },
        },
    },
    ...
});
  1. send an email with payload.sendEmail()

Actual: error is returned Expected: error is thrown

Payload Version

2.11.2

Adapters and Plugins

No response

Harmedino commented 5 months ago

working on this