I am currently working on an API in NestJs using mail sending with Mailjet service. Sending mail works locally, in a docker container, but not in the pod via my Kubernetes cluster.
The error on the API is as follows:
error: 22:45:35.712+00:00 [ExceptionsHandler] getaddrinfo ENOTFOUND in-v3.mailjet.com
I put you the configuration used for SMTP with Mailjet below with the function used to send mail. (I'm also using handlebars for email templating).
// src/providers/mailer/mailer.provider.ts
...
{
transport: {
host: mailerConfigService.host, // in-v3.mailjet.com
secure: false,
auth: {
user: mailerConfigService.user, // 9f85b17...
pass: mailerConfigService.password, // bffc4e...
},
},
defaults: {
from: mailerConfigService.from, // contact@example.com
},
template: {
dir: join(__dirname, '..', '..', 'mails', 'templates'),
adapter: new HandlebarsAdapter(),
options: {
strict: true,
},
},
}
...
// src/mails/mail.service.ts
public async sendMailConfirmation(user: UserSerializer) {
return await this.mailerService.sendMail({
to: user.email,
subject: 'Confirmez votre adresse email',
template: './mail-verification',
context: {
frontUrl: this.appConfigService.frontUrl, // https://example.com
firstName: user.firstName, // John
code: user.emailValidationCode, // 3456
},
});
}
I tried to do a nslookup
directly from the pod, but everything works, at least no error. The result of the commande:
/usr/app # nslookup in-v3.mailjet.com
Server: 10.32.0.10
Address: 10.32.0.10:53
Non-authoritative answer:
in-v3.mailjet.com canonical name = in.mailjet.com
Name: in.mailjet.com
Address: 104.199.96.85
Non-authoritative answer:
in-v3.mailjet.com canonical name = in.mailjet.com
I have exhausted all my cards, and I admit I no longer have any idea on this subject. I hope you will be able to help me! Thank you in advance.