Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

There is an error with the email configuration you have provided when on production

default discord avatar
sqveeze.last year
4

Hello,



Using next-payload deployed to vercel but i get this when payload tries to send email.


[21:08:16] ERROR (payload): There is an error with the email configuration you have provided. Error: Connection closed unexpectedly


When running it locally everything is fine and mails hit my inbox.



Config:



email: {
    logMockCredentials: process.env.NODE_ENV === "development",
    transportOptions: {
      host: process.env.SMTP_HOST,
      auth: {
        user: process.env.SMTP_USER,
        pass: process.env.SMTP_PASS,
      },
      port: +process.env.SMTP_PORT!,
      secure: false,
      tls: {
        rejectUnauthorized: false,
      },
    },
    fromName: process.env.MAIL_SENDER_NAME
    fromAddress: process.env.MAIL_SENDER_ADDRESS
  },


Env vars added to vercel.

  • discord user avatar
    jmikrut
    last year

    try running locally in production mode



    this is unfortunately something that Payload itself is not really able to diagnose, because it has to do specifically with your email connection / transport

  • default discord avatar
    sqveeze.last year

    @jmikrut still the same, works flawless locally, but what i found out: if i try to send like 10 emails some of them 1-2 is appears in my inbox. I'll try to contact Vercel.

  • discord user avatar
    jmikrut
    last year

    i don't think this has anything to do with Vercel either honestly. I think this has to do with your email service



    it

    could

    be that your mail provider has a max number of concurrent connections



    and the nature of serverless functions means that you have a lot of open connections at once, and maybe you are maxing out



    what is your mail provider? maybe do some research about serverless concurrent connection issues with your mail provider

  • default discord avatar
    sqveeze.last year

    Amazon SES. Should not be a problem i believe. I read it somewhere that vercel has a low 5s max execution time for a serverless function. Which can be also valid cause if i try it a lot of time, sometimes the email arrives.

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.