I am working on an API and I am trying to send welcome mails with my Gmail account. I have configured the necessary things and it works but after a while I get this error from Postman:
Invalid greeting. response=421 Service not available: 421 Service not available
Please what do I do?
I tried to implement a solution from a similar problem but it doesn't seem to work for me, reference: Error: Invalid greeting. response=421 Service not available: 421 Service not available
Adonis Mail config file:
import env from '#start/env'
import { defineConfig, transports } from '@adonisjs/mail'
const mailConfig = defineConfig({
default: 'smtp',
from: {
address: env.get('SMTP_USERNAME') as string,
name: '[REDACTED]',
},
replyTo: {
address: '[REDACTED]',
name: '[REDACTED]',
},
/**
* The mailers object can be used to configure multiple mailers
* each using a different transport or same transport with different
* options.
*/
mailers: {
smtp: transports.smtp({
host: env.get('SMTP_HOST'),
port: env.get('SMTP_PORT'),
/**
* Uncomment the auth block if your SMTP
* server needs authentication
*/
auth: {
type: 'login',
user: env.get('SMTP_USERNAME') as string,
pass: env.get('SMTP_PASSWORD') as string,
},
secure: false,
requireTLS: true,
}),
},
})
export default mailConfig
declare module '@adonisjs/mail/types' {
export interface MailersList extends InferMailers<typeof mailConfig> {}
}
Gmail SMTP "421 Error Code" this means recipient server is currently unable to accept your email due to high traffic or server-side limitations, resulting in the email being deferred. Essentially, the server is indicating, “try again later.” To avoid this issue, consider using a dedicated system like Elates, AWS SNS, or Brevo.