nodemailer-mailgun-transport icon indicating copy to clipboard operation
nodemailer-mailgun-transport copied to clipboard

TypeScript: 'template' does not exist in type 'Options'

Open alusev opened this issue 5 years ago • 7 comments

I cannot specify a template. I have the following code:

import nodemailer from "nodemailer";
import mg from "nodemailer-mailgun-transport";
import dotenv from "dotenv";
import Mail from "nodemailer/lib/mailer";
import pug from "pug";

dotenv.config();

const {
    MG_API_KEY = "",
    MG_DOMAIN = "",
    MG_FROM_EMAIL = "",
    MG_FROM_NAME = ""
} = process.env;

const auth = {
    auth: {
        api_key: MG_API_KEY,
        domain: MG_DOMAIN
    },
};

const nodemailerMailgun = nodemailer.createTransport(mg(auth));

export interface IMailAddress {
    name?: string;
    address: string;
}

export const sendMail = (to: Mail.Address, subject: string, templateName: string, context: any = {}) => {
    return nodemailerMailgun.sendMail({
        from: { name: MG_FROM_NAME, address: MG_FROM_EMAIL },
        to, subject,
        template: {
            name: templateName,
            engine: 'pug',
            context: context
        }
    });
}

This is the error: Object literal may only specify known properties, and 'template' does not exist in type 'Options'.

alusev avatar Jun 05 '19 12:06 alusev

Any news on this error? I have the same problem!

JaquelinaG avatar Apr 20 '20 21:04 JaquelinaG

Any updates ?

amine-louni avatar Nov 17 '21 15:11 amine-louni

any updates?

josethz00 avatar Mar 14 '22 13:03 josethz00

As we don't have an official solution yet, I just downgraded my types/nodemailer version to 6.1.0 and then the problem was solved. I also noticed that this bug is present since the 6.2.2 version.

josethz00 avatar Mar 14 '22 13:03 josethz00

Facing the same issue :/

rohanrajpal avatar Jul 18 '22 11:07 rohanrajpal

Any updates?

mechadragon01 avatar Aug 08 '22 12:08 mechadragon01