Skip to content

Latest commit

 

History

History
81 lines (60 loc) · 1.76 KB

File metadata and controls

81 lines (60 loc) · 1.76 KB

Emaillist-send-javascript-maillgunAPI

Sending emaills using javascript code.

Installation

Install Emaillist-send-javascript-maillgunAPI with npm

  npm install 

note : project cd you project files and install

  node index.js

place you emaills to list.txt.

to use

Usage/Examples

const mailgun = require("mailgun-js");
const fs = require('fs');
const DOMAIN = 'domain name';
const api_key = 'api key' ;
const mg = mailgun({apiKey: api_key, domain: DOMAIN});
const emailData = {
	from: 'exsample',
	to: 'to',
	subject: 'Promotion',
	template: "0-1",
	'h:X-Mailgun-Variables': {test: "test"}
};

const recipientList = fs.readFileSync('list.txt').toString().split('\n');

recipientList.forEach((recipient) => {
  emailData.to = recipient;

  mg.messages().send(emailData, (error, body) => {
    if (error) {
      console.log('Error sending email to ' + recipient + ': ' + error);
    } else {
      console.log('Email sent to ' + recipient);
    }
  });
});

const DOMAIN = 'domain name'; to add your domain name ina mailgun registerd

const api_key = 'api key' ; to add API key In maillgun.

you can use :

	from: 'exsample',
	to: 'to',
	subject: 'Promotion',
	template: "0-1",
	'h:X-Mailgun-Variables': {test: "test"}
};

data to send mail subject mailgun temple like emaill infomations

runing demo video

demot

Authors