• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript nodemailer.createTransport函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中nodemailer.createTransport函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createTransport函数的具体用法?TypeScript createTransport怎么用?TypeScript createTransport使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了createTransport函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: constructor

 constructor() {
     let useSMTP = !!process.env.EMAIL_SMTP;
     if (useSMTP) {
         this.transporter = createTransport(process.env.EMAIL_SMTP);
     } else {
         // default to SES
         if (process.env.EMAIL_SES) {
             this.transporter = createTransport(sesTransport(JSON.parse(process.env.EMAIL_SES)));
         } else {
             this.transporter = createTransport(sesTransport({}));
         }
     }
 }
开发者ID:TetuSecurity,项目名称:Crypt,代码行数:13,代码来源:email.ts


示例2: constructor

    constructor(generatorOptions, service?) {
        service = service || 'gmail';

        if(typeof generatorOptions === 'object'){
            this.transporter = nodemailer.createTransport({
                service: service,
                auth: {
                    xoauth2: createXOAuth2Generator(generatorOptions)
                }
            });
        } else {
            this.transporter = nodemailer.createTransport(generatorOptions);
        }
    }
开发者ID:galyna,项目名称:PalamarGroup,代码行数:14,代码来源:email.service.ts


示例3: sendEmail

	/**
	 * Sends an email.
	 *
	 * @param requestState
	 * @param {UserDocument} user Recipient
	 * @param {string} subject Subject of the email
	 * @param {string} template Name of the Handlebars template, without path or extension
	 * @param {object} templateData Data passed to the Handlebars renderer
	 * @param {string} [enabledFlag] If set, user profile must have this preference set to true
	 * @param {string} [emailAddress] If set, this email as the recipient's email instead of the user's default.
	 * @return Promise<SentMessageInfo>
	 */
	private async sendEmail(requestState: RequestState, user: UserDocument, subject: string, template: string, templateData: object, enabledFlag?: string, emailAddress?: string): Promise<SentMessageInfo> {

		const what = template.replace(/-/g, ' ');
		if (!this.emailEnabled(user, enabledFlag)) {
			logger.info(requestState, '[mailer.sendEmail] NOT sending %s email to <%s>.', what, user.email);
			return;
		}

		// generate content
		const tpl = await this.getTemplate(template);
		const text = this.wrap(tpl(templateData), 60);

		// setup email
		const email: Mail.Options = {
			from: { name: config.vpdb.email.sender.name, address: config.vpdb.email.sender.email },
			to: { name: user.name, address: emailAddress || user.email },
			subject,
			text,
		};

		// create reusable transporter object using the default SMTP transport
		const transport = nodemailer.createTransport(config.vpdb.email.nodemailer);
		logger.info(requestState, '[mailer.sendEmail] Sending %s email to <%s>...', what, (email.to as Address).address);
		const status = await transport.sendMail(email);

		if (status.messageId) {
			logger.info(requestState, '[mailer.sendEmail] Successfully sent %s mail to <%s> with message ID "%s" (%s).', what, (email.to as Address).address, status.messageId, status.response);
		} else {
			logger.info(requestState, '[mailer.sendEmail] Failed sending %s mail to <%s>: %s.', what, (email.to as Address).address, status.response);
		}
		return status;
	}
开发者ID:freezy,项目名称:node-vpdb,代码行数:44,代码来源:mailer.ts


示例4:

  .https.onCall(async (data) => {

    const transporter = nodemailer.createTransport({
      host: 'mail.sfwinterbach.com',
      port: 465,
      secure: true,
      auth: {
        user: functions.config().mailer.email,
        pass: functions.config().mailer.password
      }
    });

    const fromName = 'Kontakt';
    const fromEmail = '[email protected]';
    const to = data.to;
    const text = data.text;

    const mailOptions = {
      from: fromName + ' <' + fromEmail + '>',
      to: to,
      subject: 'Anfrage auf ' + transporter.host,
      text: text,
      html: text,
    };

    const info = await transporter.sendMail(mailOptions);
    console.log('Message sent: %s', info.messageId);
    console.log('Preview URL: %s', nodemailer.getTestMessageUrl(info));
    console.log(info);
    return info;
  });
开发者ID:Meistercoach83,项目名称:sfw,代码行数:31,代码来源:send-contact-form-to-email.ts


示例5: email_request

// EMAIL VERIFICATION
async function email_request(req, res, next) {
  try {
    let found_user:any = await pendingUser.findOne({ _id: req.body.user_id })
    if(!found_user) return res.status(500).send({message: 'User not found'})

    let duplicate_user:any = await pendingUser.findOne({ email: req.body.email })
    let email_in_use = false
    if(duplicate_user) email_in_use = duplicate_user.social_id !== found_user.social_id
    if(await realUser.findOne({ email: req.body.email }) || email_in_use || found_user.email_verified ) return res.status(500).send({ message: 'The email adress is already getting used' })

    let token:any = new emailToken({ user_id: found_user._id, token: crypto.randomBytes(16).toString('hex') })
    await token.save()

    found_user.email = CryptoJS.AES.encrypt(req.body.email, process.env.DECRYPT_KEY);

    await found_user.save()

    let confirmation_link = process.env.NODE_ENV === 'production' ? `https://signup.utopian.io` : `http://localhost:${process.env.REGISTRATION_FRONTEND_PORT}`
    let transporter = nodemailer.createTransport({ host: 'smtp.gmail.com', port: 465, secure: true, auth: { user: process.env.GOOGLE_MAIL_ACCOUNT, pass: process.env.GOOGLE_MAIL_PASSWORD } })
    let mailOptions = { from: process.env.GOOGLE_MAIL_ACCOUNT, to: req.body.email, subject: 'Utopian Email Confirmation', text: 'Hey there,\n\n' + `Please confirm your email for Utopian.io by clicking on this link: ${confirmation_link}/email/confirm/${token.token}` + '.\n' }
    await transporter.sendMail(mailOptions)
    res.status(200).send('A verification email has been sent to ' + found_user.email + '.')
  } catch (error) {
    console.error(error.message)
    res.status(500).json({ message: filter_error_message(error.message)})
  }
}
开发者ID:eastmaels,项目名称:v2.api.utopian.io,代码行数:28,代码来源:social_login.controller.ts


示例6: sendEmail

 static sendEmail(mailOptions) {
   const email = encodeURIComponent(functions.config().smtp.email);
   const password = encodeURIComponent(functions.config().smtp.password);
   const mailTransport = nodemailer.createTransport(
     `smtps://${email}:${password}@authsmtp.uchicago.edu`,
   );
   return new Promise(resolve => mailTransport.sendMail(mailOptions, resolve));
 }
开发者ID:kevmo314,项目名称:canigraduate.uchicago.edu,代码行数:8,代码来源:Config.ts


示例7: replyTemplate

export const sendReplyEmail = (address: IAddress) => {
  if (transporter == null) {
    transporter = nodemailer.createTransport({
      /**
       * 采用连接池链接,节省资源
       */
      pool: true as any,
      /**
       * qq 邮箱配置文档
       * http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=28&&no=331
       */
      host: 'smtp.qq.com',
      port: 587,
      // secure: true,
      auth: {
        user: process.env.QQSMTP_USER,
        pass: process.env.QQSMTP_PASS,
      }
    })
  }
  const html = replyTemplate(address.data)
  log.info('sendEmail.ready', {
    address,
    html
  })
  let mailOptions = {
    /**
     * 发件人,email 必须和 user 一致
     */
    from: `Said <${process.env.QQSMTP_USER}>`, // sender address
    /**
     * 收件人,多个人使用 , 号分割
     * [email protected], Mailer <[email protected]>
     */
    to: address.to, // list of receivers
    /**
     * 标题
     */
    subject: address.subject, // Subject line
    /**
     * 邮件正文
     */
    html,   // html body
  }
  /**
   * 发送邮件
   */
  transporter.sendMail(mailOptions).then(messageInfo => {
    log.info('sendEmail.success', messageInfo)
  }).catch(err => {
    log.error('sendEmail.error', err)
  })
}
开发者ID:linkFly6,项目名称:Said,代码行数:53,代码来源:email-service.ts


示例8: setup

  async setup () {
    // create reusable transporter method (opens pool of SMTP connections)
    this.insert(nodemailer.createTransport(this.config.transport))

    if (this.config.plugins) {
      for (let pluginKey of Object.keys(this.config.plugins)) {
        this.app.nodemailer.use(pluginKey, this.config.plugins[pluginKey])
      }
    }

    await this.app.nodemailer.verify()
  }
开发者ID:Magnetjs,项目名称:magnet-mailer,代码行数:12,代码来源:index.ts


示例9: sendResetMail

export function sendResetMail(to, from, content, options, done) {
	var smtpTransport = nodemailer.createTransport(options);
	var mailOptions = {
		to: to,
		from: from,
		subject: "Password Reset",
		html: content
	};
	smtpTransport.sendMail(mailOptions, (err) => {
		return done(err);
	});
}
开发者ID:cm0s,项目名称:mea2n,代码行数:12,代码来源:mail.helper.ts


示例10: function

    router.post('/contact', function (req, res) {
        console.log("Contact information " + req.body.name + "   " + req.body.email + "   " + req.body.message);
        var transporter = nodemailer.createTransport({
            service: 'Gmail',
            auth: config.mail
        });
        config.mailOptions.subject = 'Cleaning customer ' + req.body.name;
        config.mailOptions.text = req.body.message + "\n" + "From: " + req.body.email;
        transporter.sendMail(config.mailOptions, function (error, info) {
///            res.redirect("/");
        });
    });
开发者ID:mortonprod,项目名称:CleaningWebsite,代码行数:12,代码来源:post.ts


示例11:

postman.init = () => {

   const email = mailer.createTransport({
       service: appConfig.smtp_service.name,
       auth: {
           user: appConfig.smtp_service.username,
           pass: appConfig.smtp_service.password
       }
   });

   postman._email = email;

};
开发者ID:raelgor,项目名称:zen-arena,代码行数:13,代码来源:postman.ts


示例12:

    nodemailer.createTestAccount((_err, _account) => {
      const transporter = nodemailer.createTransport(config.mail);

      // setup email data with unicode symbols
      const mailOptions = {
        from: `"RAP2 Notifier" <${config.mailSender}>`, // sender address
        to,
        subject,
        html,
      };

      // send mail with defined transport object
      transporter.sendMail(mailOptions)
    })
开发者ID:tonyjt,项目名称:rap2-delos,代码行数:14,代码来源:mail.ts


示例13: getTransport

export async function getTransport (): Promise<nodemailer.Transporter> {
  try {
    let config = await getMailConfig(process.env.NODE_ENV || 'development')
    let logger = getLogger(config.logfile)
    let transport = nodemailer.createTransport(mailGun({
      auth: {
        api_key: config.api_key,
        domain: config.domain
      },
      logger: logger
    }))
    return transport
  } catch (err) {
    throw err
  }
}
开发者ID:chipp972,项目名称:stock_manager_api,代码行数:16,代码来源:transport.ts


示例14: function

 sendEmail: function (to: string, subject: string, content: string, callback: void) {
     var mailer = require("nodemailer");
     var smtpTransport = mailer.createTransport("SMTP", {
         service: "Gmail",
         auth: {
             user: '[email protected]',
             pass: 'ttlpta840465'
         }
     });
     var mailOptions = {
         to: to,
         subject: subject,
         text: content
     };
     smtpTransport.sendMail(mailOptions, callback);
 },
开发者ID:ttlpta,项目名称:nodejs-ecomerce,代码行数:16,代码来源:helper.ts


示例15: constructor

	constructor() {
		super();

		this.smtpOptions = {
			host: Mailer.host,
			port: Mailer.port,
			secure: Mailer.secureConnection,
			auth: {
				user: Mailer.username,
				pass: Mailer.password,
			},
			requireTLS: Mailer.requireTLS,
		};
		this.transporter = Nodemailer.createTransport(this.smtpOptions);
		this.validator = new Validator();
		this.emailTemplates = new EmailTemplates();
	}
开发者ID:Event-Starter-Kit,项目名称:website,代码行数:17,代码来源:emailService.ts


示例16: function

        handler: async function (req, res, next) {
            const model: Requests.ForgotPassword = req.validatedBody;
            let user: User;

            if (!UserDb.exists(model.username.toLowerCase())) {
                // Do not let the client know that the username does not exist.

                return next();
            }

            const token = await seal({
                exp: Date.now() + ((1000 * 60) * 90), // 90 minutes in milliseconds
                username: model.username,
            } as ResetToken, Constants.IRON_PASSWORD);

            const url = `${req.domainWithProtocol}/auth/reset-password?token=${encodeURIComponent(token)}`;
            const message = {
                content: {
                    from: {
                        name: "Support",
                        email: `support@${Constants.EMAIL_DOMAIN}`,
                    },
                    subject: `[${Constants.APP_NAME}] Reset your password.`,
                    html: `<p>Hello,</p><p>You recently requested to reset your password for ${Constants.APP_NAME}. Please click the link below to reset your password.</p><p><a href='${url}'>Click here to reset your password.</a></p><p>If you did not request a password reset, please ignore this email or reply to let us know. This password reset is only valid for the next 90 minutes.</p><p>Thanks, <br/> The ${Constants.APP_NAME} Team</p>`
                },
                recipients: [{
                    address: {
                        email: model.username,
                    }
                }]
            }

            //Send the password reset email
            const transporter = createTransport({ transport: 'sparkpost', sparkPostApiKey: Constants.SPARKPOST_API_KEY } as any);

            transporter.sendMail(message as any, (error, info) => {
                if (error) {
                    return next(boom.wrap(error));
                };

                res.json({});

                return next();
            });
        }
开发者ID:nozzlegear,项目名称:Gearworks,代码行数:45,代码来源:users.ts


示例17: sendResetPasswordEmail

 function sendResetPasswordEmail(user: UserModel, done: Function) {
   const transporter = nodemailer.createTransport({
     service: "SendGrid",
     auth: {
       user: process.env.SENDGRID_USER,
       pass: process.env.SENDGRID_PASSWORD
     }
   });
   const mailOptions = {
     to: user.email,
     from: "[email protected]",
     subject: "Your password has been changed",
     text: `Hello,\n\nThis is a confirmation that the password for your account ${user.email} has just been changed.\n`
   };
   transporter.sendMail(mailOptions, (err) => {
     req.flash("success", { msg: "Success! Your password has been changed." });
     done(err);
   });
 }
开发者ID:babula38,项目名称:TypeScript-Node-Starter,代码行数:19,代码来源:user.ts


示例18: callback

let send = (message:Message, callback:Callback):void => {
  let transporter = nodeMailer.createTransport({
    service: 'gmail',
    auth: {
      user: GMAIL_APP_EMAIL,
      pass: GMAIL_APP_PASSWORD
    }
  }, {
    from: GMAIL_SENDER_EMAIL
  });
  transporter.sendMail(message, (error, info) => {
    if (error) {
      console.log('Message not sent: ' + error);
      callback(false);
    }
    console.log('Message sent: ' + info.response);
    callback(true);
  });
};
开发者ID:ouq77,项目名称:portfolio-web,代码行数:19,代码来源:node.mailer.ts


示例19: sendMail

    async sendMail(ctx, next) {
        const id = ctx.request.body['username'],
            email = ctx.request.body['email'];
        let transporter = nodemailer.createTransport({
            service: 'QQ',
            auth: {
                user: '[email protected]',
                pass: 'puvisfhhlggpbdjg'
            }
        });

        let code = (new Date).getTime();
        dict[id] = code;

        let mailOptions = {
            from: '[email protected]', // sender address
            to: email,
            // to: '[email protected]', // list of receivers
            subject: '某某某网站邮箱验证', // Subject line
            text: '某某某网站邮箱验证', // plaintext body
            html: `
                <div>
                    <p>${id},您好:</p>
                    <p style="text-indent: 2em;">感谢您使用某某某网站!</p>
                    <p style="text-indent: 2em;">请点击如下链接,以完成您账户的注册:</p>
                    <p style="text-indent: 2em;">
                        <a href='http://192.168.99.100:8080/api/v2/user/${id}/verifiy-code/${code}'>http://192.168.99.100:8080/api/v2/user/${id}/verifiy-code/${code}</a>
                    </p>
                    <p style="text-indent: 2em;">(如果不能点击该链接地址,请复制并粘贴到浏览器的地址输入框)</p>
                </div>
            ` // html body
        };

        transporter.sendMail(mailOptions, function (error, info) {
            if (error) {
                console.error(error);
            } else {
                console.log('Message sent: ' + info.response);
            }
        });
        ctx.body = 'success';
    }
开发者ID:wangxin0709,项目名称:csc-scms-node-koa,代码行数:42,代码来源:user-controller.ts


示例20: sendEmail

    public sendEmail(toEmailAddress: string, bccAddresses: string, subject: string, body: string) {
        var smtpTransport: Transport = nodemailer.createTransport("SMTP", this.smtpOptions.getNodemailerSmtpOptions());

        var message: any = {
            from: this.fromEmail,
            to: toEmailAddress,
            bcc: bccAddresses,
            subject: subject,
            html: body
        };

        smtpTransport.sendMail(message, (error) => {
            if (error) {
                this.logger.log("Mail error: " + error.message);
            }
            else {
                this.logger.log("Sent email to " + toEmailAddress + " bcc: " + bccAddresses + ": " + subject);
            }
            smtpTransport.close();
        });
    }
开发者ID:smithgeek,项目名称:DevCommunity,代码行数:21,代码来源:Mailer.ts



注:本文中的nodemailer.createTransport函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript nodemiral.taskList函数代码示例发布时间:2022-05-25
下一篇:
TypeScript nodegit.Signature类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap