Skip to content

PavelNaumenko/mail-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mail-bot

Usage

import mailer from '../../server/core/mailer';

Init

mailer.init({

	sender: 'Test Bot <bot@85.143.223.226>',
	driver: 'gmail',
	interval: 2000,
	attachLimit: {

		txt: 1000,
		jpeg: 20000000

	}

});

Possible options values:

  • sender (Required) String - set field 'from' for sended emails
  • driver (Required) String - name of email driver
  • interval (Required) String - set interval time for sync with email service for parse list of mails
  • attachLimit (Required) Object - set allowed types and their max size

Start server

Start server and watch for new emails.

let timerId = mailer.start();

Stop server

Stop server and unwatch for new emails.

mailer.stop(timerId);

Listen for new messages

mailer.on('message', (mail) => {

	console.log(mail);

});

Send email

mailer.send(
  {
    subject: 'some subject',
    message: 'some message',
    to: ['pnaumenko95@gmail.com'],
    attachments:
    [{

        name: 'picture.jpeg',
        attach: 'https://static.pexels.com/photos/96918/pexels-photo-96918.jpeg',
        type: 'url'
        
    }],
    date: Date.now()

	});

Possible options values:

  • subject (Required) String - email subject
  • message (Required) String - email message
  • to (Required) String or Array - email recipient or list of recipients
  • attachments (Optional) Array - email attachments
  • date (Required) Date(UTC) - date for delayed sending email
  • sender (Optional) String - update field 'from' for sended emails

sendMailAfter

Add your count to type that you want to set.

date: mailer.setSendedData({ seconds: dateNow.getSeconds() + 7 })

Possible param values:

  • year
  • month
  • date
  • hours
  • minutes
  • seconds

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages