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.
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
@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.
i don't think this has anything to do with Vercel either honestly. I think this has to do with your email service
it
couldbe 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
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
Discord
online
Get dedicated engineering support directly from the Payload team.