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


TypeScript mailgun-js.default函数代码示例

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


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

示例1: sendEmail

  async sendEmail() {
    const { subject, email, message } = this.fields
    const { MAILGUN_KEY } = process.env

    const data = {
      from: email,
      to: 'gabrielsiedler@gmail.com',
      subject: `gs.ninja (${subject})`,
      text: message,
    }

    if (!MAILGUN_KEY) {
      console.error('No mailgun key provided.')
      printEmail(data)

      return
    }

    const MailGunClient = mailgun({
      apiKey: MAILGUN_KEY,
      domain: 'gabriel.siedler.ninja',
    })

    await MailGunClient.messages().send(data, (error) => {
      printEmail(data)

      if (error) {
        console.log(`Mailgun error: ${error}`)
        bugsnag.notify(`Mailgun error: ${error}`)
      }
    })
  }
开发者ID:gabrielsiedler,项目名称:gabriel.siedler.ninja,代码行数:32,代码来源:contact.ts

示例2: sendMail

  public async sendMail(emailMessage: EmailMessage): Promise<void> {
    if (process.env.MAILGUN_API_KEY === undefined) {
      console.error("Mailgun API Key not set");
      return;
    }
    const apiKey: string = process.env.MAILGUN_API_KEY || "";
    const domain: string = process.env.MAILGUN_DOMAIN || "";
    const mg = mailgun({ apiKey, domain });

    const mailgunEnvelope = {
      "from": emailMessage.from,
      "to": emailMessage.to,
      "bcc": emailMessage.bcc,
      "subject": emailMessage.subject,
      "text": emailMessage.text,
      "h:sender": emailMessage.from,
    };

    try {
      await mg.messages().send(mailgunEnvelope);
    } catch (e) {
      console.error(e);
    }
  }
开发者ID:snickroger,项目名称:FantasyMovieLeague,代码行数:24,代码来源:emailSender.ts

示例3: sendEmail

function sendEmail() {
  const mailer = mailgun({ apiKey: api_key, domain: domain });
  let from_email = $('input[name="from"]').val(),
      subject = $('input[name="subject"]').val(),
      content = $('textarea[name="content"]').val(),
      html = $('.email iframe').contents().find('html').html();
  let email_fields = $('input[name="email"]').val(),
      name_fields = $('input[name="name"]').val();
  let query = $('dd#query-query').text(),
      collection = '',
      bits = query.split('@');
  if (query === '') {
    console.error('must select query');
    return;
  }
  collection = bits[0];
  query = bits[1];
  if (from_email === '') {
    console.error('from field cannot be empty');
    return;
  }
  if (subject === '') {
    console.error('subject field cannot be empty');
    return;
  }
  if (content === '') {
    console.error('content cannot be empty');
    return;
  }
  if (email_fields === '') {
    console.error('email cannot be empty');
    return;
  }
  if (name_fields === '') {
    console.error('name cannot be empty');
    return;
  }
  mongo.find(collection, JSON.parse(query), (error, data) => {
    if (error) {
      console.error('query failed');
      return;
    } else {
      for (let i=0; i<data.length; i++) {
        let email = getNestedProperty(data[i], email_fields),
            name = getNestedProperty(data[i], name_fields);
        let request = {
          from: from_email,
          to: email,
          subject: subject,
          text: content,
          html: Mustache.render(html, {name: name})
        };
        mailer.messages().send(request, function(error, body) {
          if (error) {
            console.error(error);
          } else {
            console.log(body);
          }
        });
      } /* END FOR */
    }
  }); /* END MONGO FIND */  
}
开发者ID:hack-rpi,项目名称:Email-Board,代码行数:63,代码来源:email.ts

示例4: sendMail

'use strict';

var config = require('../config/config.js');
var mailgun = require('mailgun-js');

export var mailer = mailgun({
  apiKey: config.email.mailgun.api_key,
  domain: config.email.mailgun.domain
});

export function sendMail(data, cb) {
  mailer.messages().send(data, cb);
}
开发者ID:tebbon,项目名称:nappikauppa2,代码行数:13,代码来源:mail.ts

示例5: constructor

    constructor(public app) {
        const emailSender = mailgun(mailgunConfig);

        app.use((err, req, res, next) => {
            res.status(401).json({ message: 'Unauthorized request' });
        });

        app.post('/register', (req, res) => {
            let email = req.body.email;
            const name = req.body.name;
            const picture = req.body.picture;

            if (!email || !name) {
                res.status(400).send({ message: '' });
                return;
            }

            email = email.toLowerCase();

            r.table('players').filter({ email }).then((user) => {
                if (!user.length) {
                    r.table('players').insert({
                        id: r.uuid(),
                        email,
                        name,
                        picture,
                        activity: { questionsPlayed: [] },
                    }).then((r) => {
                        res.status(200).send({});
                    })
                } else {
                    res.status(400).send({ message: 'User is already exist' });
                }
            })
        });

        app.post('/get-token', (req, res) => {
            const presenter = req.body.presenter;

            if (presenter) {
                const options = { expiresIn: '365d' };
                return jwt.sign({ presenter: true }, secret, options, (err, token) => {
                    res.status(200).send({ token });
                });
            }

            const email = req.body.email.toLowerCase();
            const redirect = req.body.redirect;
            r.table('players').filter({ email }).then((users) => {
                if (users.length) {
                    crypto.randomBytes(12, (err, buffer) => {
                        const token = buffer.toString('hex');
                        const clientRedirect = req.get('origin') + '/validate-token';
                        const user = users[0];

                        r.table('tokens').insert({ email, token }).then(() => {
                            const userName = user.name;
                            const confirmLink = `${clientRedirect}/${encodeURIComponent(redirect)}/${encodeURIComponent(email)}/${token}`;
                            const body =
                                `Hi ${userName},\n` +
                                'Welcome to Bullshit!\n' +
                                '\n' +
                                `Please take a second to confirm ${email} as your email address:\n` +
                                `${confirmLink}\n` +
                                'Once you do, you’ll be able to play Bullshit with your friends!\n' +
                                '\n' +
                                'High fives,\n' +
                                'Bullshit';

                            if (process.env.NODE_ENV === 'development') {
                                console.log(confirmLink);
                                return res.status(200).send({});
                            }

                            fs.readFile(path.join(__dirname, '../../public/signin-template.html'), 'utf8', (err, html) => {
                                html = html.replace('${userName}', userName);
                                html = html.replace('${email}', email);
                                html = html.replace('${confirmLink}', confirmLink);

                                const mail = mailcomposer({
                                    from: 'Bullshit <login@mail.bullshit.wtf>',
                                    to: email,
                                    subject: '[Bullshit] Confirm your email at Bullshit',
                                    body,
                                    html,
                                });

                                mail.build((err, message) => {
                                    if (err) {
                                        console.log(err);
                                        return res.status(500).send({});
                                    }

                                    const dataToSend = {
                                        to: email,
                                        message: message.toString('ascii')
                                    };

                                    emailSender.messages().sendMime(dataToSend, (err, body) => {
                                        if (err) {
//.........这里部分代码省略.........
开发者ID:radotzki,项目名称:bullshit-server,代码行数:101,代码来源:index.ts


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