We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I set up this for my backend service:
import * as MailGun from 'nodemailer-mailgun-transport'; import { createTransport } from 'nodemailer'; MailerModule.forRootAsync({ inject: [ConfigService], useFactory: (configService: ConfigService) => { console.log({ api_key: configService.get<string>('MAILGUN_API_KEY'), domain: configService.get<string>('MAILGUN_DOMAIN'), }); return { transport: createTransport( MailGun({ auth: { api_key: configService.get<string>('MAILGUN_API_KEY'), domain: configService.get<string>('MAILGUN_DOMAIN'), }, }), ), defaults: { from: '"Incash Option" <[email protected]>', }, template: { dir: join(process.cwd(), 'dist', 'libs', 'mail', 'templates'), adapter: new HandlebarsAdapter(), options: { strict: true, }, }, }; }, }),
And I will received the response:
Error: connect ECONNREFUSED ::1:587
If I just used a simple like this. Everything is ok
const transporter = createTransport( MailGun({ auth: { api_key: configService.get<string>('MAILGUN_API_KEY'), domain: configService.get<string>('MAILGUN_DOMAIN'), }, }), ); transporter.sendMail({ from: '"Incash Option" <[email protected]>', to: '[email protected]', subject: 'Incash Option', text: 'Incash Option', })
Please let me know what the right way to use the MailGun service is. Thanks
The text was updated successfully, but these errors were encountered:
Hi @tungnt2k i just got same error with yours and find out the solution. you just need to add .transporter at the end of createTransport() function.
.transporter
createTransport()
here's how you fix it. hope this answer helps you and others that might face same issue like ours.
const transport = MailGun({ auth: { apiKey: this.configService.get('MAILGUN_API_KEY'), domain: this.configService.get('MAILGUN_DOMAIN'), }, }); return { transport: createTransport(transport).transporter, defaults: { from: '"test" <[email protected]>', }, template: { dir: join(process.cwd(), 'dist', 'libs', 'mail', 'templates'), adapter: new HandlebarsAdapter(), options: { strict: true, }, }, };
Sorry, something went wrong.
No branches or pull requests
I set up this for my backend service:
And I will received the response:
If I just used a simple like this. Everything is ok
Please let me know what the right way to use the MailGun service is.
Thanks
The text was updated successfully, but these errors were encountered: