How to use the nodemailer.createTestAccount function in nodemailer

To help you get started, we’ve selected a few nodemailer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github obiwankenoobi / react-express-boilerplate / server / src / services / activateAccountEmail.ts View on Github external
return new Promise((resolve, reject) => {
    // Generate test SMTP service account from ethereal.email
    // Only needed if you don't have a real mail account for testing
    nodemailer.createTestAccount((err, mailAcc) => {
      // create reusable transporter object using the default SMTP transport
      const transporter = nodemailer.createTransport({
        host: process.env.smtp,
        port: 465,
        secure: true, // true for 465, false for other ports
        auth: {
          user: process.env.nodemailerEmail, // generated ethereal user
          pass: process.env.nodemailerPw // generated ethereal password
        }
      });
      console.log(process.env.nodemailerEmail, process.env.nodemailerPw);
      // setup email data with unicode symbols
      const mailOptions = {
        from: process.env.nodemailerEmail, // sender address
        to: email, // list of receivers
        subject: `thanks for signing up (: `, // Subject line
github ForbesLindesay / authentication / packages / send-message / src / index.ts View on Github external
function getEtherealTransportUnCached() {
  return createTestAccount().then(auth =>
    createTransport({
      host: 'smtp.ethereal.email',
      port: 587,
      secure: false, // true for 465, false for other ports
      auth,
    }),
  );
}
let testTransport: null | Promise = null;
github chanlito / untitled / server / lib / mailer.ts View on Github external
async createTransporter() {
    if (process.env.NODE_ENV === 'development') {
      const {
        smtp: { host, port, secure },
        user,
        pass,
      } = await nodemailer.createTestAccount();
      this.transporter = nodemailer.createTransport({
        host,
        port,
        secure,
        auth: { user, pass },
      });
    } else {
      this.transporter = nodemailer.createTransport({
        // TODO: provide a production info here
      });
    }
    return this.transporter;
  }
github shindesharad71 / Anstagram / server / src / libs / mailer.ts View on Github external
const sendVerificationMail = async () => {
    try {
        const emailBody = await prepareEmailBody();
        const account = await nodemailer.createTestAccount();

        const transporter = nodemailer.createTransport({
            host: 'smtp.ethereal.email',
            port: 587,
            secure: false, // true for 465, false for other ports
            auth: {
                user: account.user, // generated ethereal user
                pass: account.pass // generated ethereal password
            }
        });

        // setup email data with unicode symbols
        const mailOptions = {
            from: '"Fred Foo 👻" ', // sender address
            to: 'shindesharad71@gmail.com', // list of receivers
            subject: "Hello ✔", // Subject line
github fullstack-build / fullstack-one / packages / notifications / lib / NotificationsEmail.ts View on Github external
private async boot(): Promise {
    // create transport with settings
    if (this.CONFIG.testing) {
      createTestAccount((err, account) => {
        if (err != null) {
          this.logger.warn("testingAccount.creation.error", err);
          throw err;
        } else {
          this.logger.trace("testingAccount.creation.success", account.user);
        }

        this.createTransport({
          host: account.smtp.host,
          port: account.smtp.port,
          secure: account.smtp.secure,
          auth: {
            user: account.user, // generated ethereal user
            pass: account.pass // generated ethereal password
          }
        });
github developer239 / node-type-orm-graphql / src / modules / Core / services / mailer.ts View on Github external
export const sendEmail = async (params: IMailerParams) => {
  const account = await nodemailer.createTestAccount()

  const transporter = nodemailer.createTransport({
    host: 'smtp.ethereal.email',
    port: 587,
    // true for 465, false for other ports
    secure: false,
    auth: {
      user: account.user,
      pass: account.pass,
    },
  })

  const mailOptions = {
    from: params.from,
    to: params.to,
    subject: params.subject,
github kevenleone / graphscript / src / utils / globalMethods.ts View on Github external
export async function MailerCredentials(): Promise {
  const { MAIL_HOST, MAIL_PORT, MAIL_USER, MAIL_PASS, ENVIRONMENT } = defaults;
  const config: MailConfig = {
    host: MAIL_HOST,
    port: MAIL_PORT,
    auth: {
      user: MAIL_USER,
      pass: MAIL_PASS,
    },
  };
  if (ENVIRONMENT !== 'production' && !MAIL_USER && !MAIL_PASS) {
    const { user, pass } = await nodemailer.createTestAccount();
    config.auth.user = user;
    config.auth.pass = pass;
  }

  return config;
}