当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript nodemailer.createTransport函数代码示例

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


在下文中一共展示了createTransport函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 = 'kontaktformular@sfwinterbach.com';
    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
    /**
     * 收件人,多个人使用 , 号分割
     * mailer@nodemailer.com, Mailer <mailer2@nodemailer.com>
     */
    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: 'tuananhdev200898@gmail.com',
             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


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