npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mailscripter

v1.4.0

Published

Mail Sender

Downloads

21

Readme

MailScripter

Features

mailscripter is a powerful and easy-to-use Node.js module designed to handle and automate email-related tasks in your applications. With mailscripter, you can easily send emails both Synchronously and Asynchronously.

Installation

To install the package, run the following command:

npm install mailscripter

Usage

Using ES6 import.

import {mailScripter} from 'mailscripter';

Using CommonJS require.

const {mailScripter} = require('mailscripter');

Get script-string

To get your-script-string, Goto Google Apps Script and login with your gmail you want to use for send email.

then create a New Project, and name the project. then paste the code given below and click save button.


function doGet(e){
  return ContentService.createTextOutput("Get Method Not Allowed!");
}

function doPost(e) {
  try {
    var formData = e.parameter;
    
    var recipient = formData.recipient;
    var subject = formData.subject;
    var htmlBody = formData.body;
    MailApp.sendEmail(recipient,subject,"",{htmlBody:htmlBody});
    return ContentService.createTextOutput(JSON.stringify({status:"success",message:"Email sent successfully."}))
                         .setMimeType(ContentService.MimeType.JSON);
  } catch (error) {
    return ContentService.createTextOutput(JSON.stringify({status:"failure",message:error.message}))
                         .setMimeType(ContentService.MimeType.JSON);
  }
}

then deploy with New Dployment.

Configure deployment by,

  1. press the gear icon and chose Web app.
  2. give New Description,
  3. Chose Execute as Me(your-email),
  4. Chose Who has access as Anyone

then Click on deploy and Authorize access your gmail to send mail permision. then chose your Gmail Account, Click on Advanced option and click on Go to your project name (unsafe), then click on Allow button.

copy the Web app URL and store securly in .env file.

Create a new instance.

const mailer = new mailScripter('your-script-string');//"https://script.google.com/xxxxxxxxxxxxxxx";

Sending an Email with callback

To send an email, use the "sendMail()" method. This method requires two parameters:

emailDetails: An object containing the following properties:

{
email: "The recipient's email address",
subject: "The subject of the email",
content: "The content of the email"
}

callback function(Optional): A function that receives one parameter, which returns the response of the mail send status.

  const emailDetails = {
  email: '[email protected]',
  subject: 'Hello from mailscript',
  content: 'This is a test email using mailscript Text/ HTML'
};

mailer.sendMail(emailDetails, (response) => {
    console.log(response) //return a object {status:'success':message:'Email sent successfully.'}
});

Sending an Email with Promise

Alternatively, you can send an email using the "sendMailAsync()" method, which returns a promise. It takes one parameter, an emailDetails : An object containing the following properties:

{
email: "The recipient's email address",
subject: "The subject of the email",
content: "The content of the email"
}

You can handel the promise with .then() and .catch() or with async/await.


const emailDetails = {
    email: "[email protected]",
    subject: "Your Email Subject",
    content: `This is the content of the email as Text/ HTML.`
};

mailer.sendMailAsync(emailDetails)
    .then(response => {
        console.log('Mail send status:', response); //return a object {status:'success':message:'Email sent successfully.'}
    })
    .catch(error => {
        console.error('Failed to send email:', error);
    });

This module ignore send email for domain test.com/ test.in

Contact

For any question or concerns, Please contact the maintainer: -Bikram Sahoo