Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var nodemailer = require('nodemailer')
- var transporter = nodemailer.createTransport("SMTP", {
- host: "smtp.domain.com",
- secureConnection: false,
- port: 587,
- auth: {
- user: "email@domain.com",
- pass: 'password'
- },
- tls: {
- ciphers:'SSLv3'
- }
- })
- const json = {
- 'email@domain.com': 'John Doe'
- }
- const arr = Object.keys(json).map((key)=>{
- return {email: key, name: json[key]}
- })
- let total = arr.length
- const send = ()=>{
- if (!arr[index]) {
- console.log('Finished')
- return
- }
- const {name, email} = arr[index]
- var mailOptions = {
- from: 'John Doe <email@domain.com>',
- to: `${name} <${email}>`,
- subject: 'This is my subject',
- text:
- `
- To ${name}
- This is an email
- John Doe.
- `
- }
- transporter.sendMail(mailOptions, function(error, info){
- if(error){
- console.log(error)
- } else {
- console.log(`Message sent: ${name} <${email}> ${(index+1)} of ${total} (${(index/total * 100).toFixed(1)})%`)
- }
- index++
- setTimeout(()=>{
- send()
- },3000)
- })
- }
- send()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement