How to use node-mailjet - 9 common examples

To help you get started, we’ve selected a few node-mailjet 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 Okazari / FatesEditions / routes / portal.js View on Github external
const express = require('express')
const router = express.Router()
const User = require('../models/UserModel')
const jwt = require('jsonwebtoken')
const SHA512 = require('crypto-js/sha512')
const mailjet = require('node-mailjet')
  .connect('5ef5f026c64d5e328dc7a113ba724e76', 'b4f9b9ec04a009f3da2167ddd0093a38')

router.post('/login', (req, res, next) => {
  User.findOne({ username: req.body.username })
    .then((player) => {
      if (!player || SHA512(req.body.password) != player.password) {
        res.sendStatus(403)
      } else {
        // TODO Exporter le secret dans la config
        player.password = null
        const token = jwt.sign({ user: player }, 'mysecretstory', { expiresIn: 3600 })
        res.send({ token, user: player })
      }
    }, err => next(err))
})
github attilabuti / vscode-mjml / src / email.ts View on Github external
private async mailjet(
        subject: string, recipients: string, html: string, attachments: Attachments[]
    ): Promise {
        const recipientList: Array<{ Email: string }> = recipients.split(",").map((emailAddress: string) => {
            return { Email: emailAddress };
        });

        await mailjetConnect(
            workspace.getConfiguration("mjml").mailjetAPIKey,
            workspace.getConfiguration("mjml").mailjetAPISecret
        ).post("send").request({
            "FromEmail": workspace.getConfiguration("mjml").mailSender,
            "FromName": workspace.getConfiguration("mjml").mailFromName,
            "Html-part": html,
            "Inline_attachments": attachments,
            "Recipients": recipientList,
            "Subject": subject
        }).then(() => {
            window.showInformationMessage("Mail has been sent successfully.");
        }).catch((error: any) => {
            window.showErrorMessage(error.message);
        });
    }
github secret-tech / backend-ico-dashboard / src / services / mailjet.service.ts View on Github external
constructor() {
    this.api = require('node-mailjet').connect(config.email.mailjet.apiKey, config.email.mailjet.apiSecret);
  }
github octo-webf / octo-job-board / server / src / infrastructure / mailing / mailjet.js View on Github external
function sendEmail(options) {
  const mailjet = nodeMailjet.connect(mailjetConfig.apiKey, mailjetConfig.apiSecret);
  return mailjet
    .post('send')
    .request(_formatPayload(options));
}
github betagouv / preuve-covoiturage / api / providers / notification / src / mail / MailjetDriver.ts View on Github external
debug: boolean;
      from: {
        email: string;
        name: string;
      };
      defaultSubject: string;
    },
    driverConfig: {
      public: string;
      private: string;
      options: MailjetConnectOptionsInterface;
    },
  ) {
    this.config = generalConfig;
    const connectOptions: MailjetConnectOptionsInterface = driverConfig.options;
    this.mj = nodeMailjet.connect(driverConfig.public, driverConfig.private, {
      version: 'v3.1',
      ...connectOptions,
    });
  }
github betagouv / preuve-covoiturage / api / services / notification / src / providers / MailjetProvider.ts View on Github external
async boot(): Promise {
    const connectOptions: MailjetConnectOptionsInterface = this.configProvider.get('mail.connectOptions');
    this.config = this.configProvider.get('mail.mailjet');
    this.mj = nodeMailjet.connect(this.config.public, this.config.private, connectOptions);
  }
github soixantecircuits / altruist / actions / mailjet.js View on Github external
'use strict'

const settings = require('nconf').get()
const mediaUtils = require('../src/lib/media')
const mailjet = require('node-mailjet').connect(settings.actions.mailjet.apiKey, settings.actions.mailjet.secretKey)

function run (options, request) {
  return new Promise((resolve, reject) => {
    if (!options.fromEmail && !settings.actions.mailjet.fromEmail) {
      return reject({
        error: 'missing parameter',
        details: 'The "fromEmail" parameter is missing in the request.'
      })
    }
    if (!options.recipients) {
      return reject({
        error: 'missing parameter',
        details: 'The "recipients" parameter is missing in the request.'
      })
    }
    if (!options.subject) {
github mjmlio / mjml-app / src / helpers / sendEmail.js View on Github external
export default function sendEmail(opts) {
  const { content, Subject, APIKey, APISecret, SenderName, SenderEmail, TargetEmails } = opts

  const mj = nodeMailjet.connect(APIKey, APISecret)
  const send = mj.post('send')
  const Recipients = TargetEmails.map(t => ({ Email: t }))

  return send.request({
    FromEmail: SenderEmail,
    FromName: SenderName,
    Subject,
    'Html-part': content,
    Recipients,
  })
}
github sandorTuranszky / production-ready-expressjs-server / src / utils / jobQueue / integrations / mailjet.js View on Github external
'use strict';

/**
 * MailJet API for sending basic email
 * @url https://dev.mailjet.com/guides/?javascript#sending-a-basic-email
 *
 * TODO: templates @url https://dev.mailjet.com/guides/?javascript#using-a-template
 */
const config = require('config');
const mailjet = require('node-mailjet').connect(
  config.get('mailjet.api_key'),
  config.get('mailjet.secret'),
);

const sendEmail = data =>
  mailjet.post('send', { version: 'v3.1' }).request({
    Messages: [
      {
        From: {
          Email: data.fromEmail,
          Name: data.fromName,
        },
        To: [
          {
            Email: data.to,
            Name: data.nameTo,

node-mailjet

Mailjet API client

MIT
Latest version published 4 months ago

Package Health Score

69 / 100
Full package analysis

Popular node-mailjet functions