當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。