Coder Social home page Coder Social logo

automatic-email-sender's Introduction

Automatic Email Sender

This Node.js project leverages nodemailer, node-cron,and googleapis to create an automated email sender. It allows users to schedule emails for delivery using cron jobs and provides a straightforward setup.

Installation

  1. Clone the repository:

    git clone https://github.com/dhelafrank/Automatic-Email-Sender.git
  2. Navigate to the project directory:

    cd Automatic-Email-Sender
  3. Install dependencies using npm or yarn:

    npm install
    # or
    yarn install
  4. Create a .env file in the project root and add the following information:

    CLIENT_ID=your_google_client_id
    CLIENT_SECRET=your_google_client_secret
    REFRESH_TOKEN=your_oauth_refresh_token
    USER_EMAIL=[email protected]
  5. Linux or Unix users could setup the project by running the setup.sh file in the Project's root directory

Starting the Script

To start the script, use the following command:

npm start
# or
yarn start

Disclaimer

Note: Ensure compliance with applicable laws and regulations when sending emails. Respect recipients' privacy and adhere to ethical email practices. This script is intended for legitimate and consensual use only.

Usage

Immediate Email Sending

You can trigger immediate email sending by uncommenting the function call in /app.js:

selectAndDeleteRandomMessage("[email protected]", "Email Subject");

Scheduled Email Sending

To schedule emails, the cron job is set to run every day at midnight:

cron.schedule('0 0 * * *', () => {
  selectAndDeleteRandomMessage("[email protected]", "Email Subject");
});

you can modify the schedule as you want

Function Details

The selectAndDeleteRandomMessage function, found in /app.js, takes two arguments:

  1. Recipient Email Address
  2. Email Subject

Feel free to customize the function call with the desired recipient and subject.

Caution: Respect email recipients' consent and provide an option to unsubscribe from the mailing list.

For more details, refer to the Google Cloud Console for obtaining CLIENT_ID and CLIENT_SECRET and OAuth Playground for obtaining the REFRESH_TOKEN.

automatic-email-sender's People

Contributors

dhelafrank avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.