kirbyk / mailer

Send emails with Mailgun via the command line or other js applications.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mailer

Send emails with Mailgun via the command line or other js applications.

install

production (doesn't currently exist)

$ npm install mailer

development (use this one)

$ git clone https://github.com/kirbyk/mailer.git
$ cd mailer
$ npm install
$ npm link

usage

command line

$ MAILGUN_API_KEY="XXXXXXXXXX"
$ mailer --config example/config.yaml

example/config.yaml

domain: 'kirby.xyz'
from: 'Kirby <hi@kirby.xyz>'
to: 'email@example.com'
subject: 'Hello'
html: 
  file: 'email.html'
text:
  file: 'email.txt'

example/email.html

<h1>Hello world!<h1>

example/email.txt

Hello world!

code

const mailer = require('mailer');

const options = {
  domain: 'kirby.xyz',
  from: 'Kirby <hi@kirby.xyz>',
  to: 'email@example.com',
  subject: 'Hello',
  html: {
    inline: '<h1>Hello world!</h1>'
  },
  text: {
    inline: 'Hello world!'
  },
};

mailer(options, (err, info) => {
  if (err) {
    return console.error(err.toString());
  }
  return console.log('Response: ' + JSON.stringify(info));
});

About

Send emails with Mailgun via the command line or other js applications.

License:MIT License


Languages

Language:JavaScript 99.3%Language:HTML 0.7%