Giter VIP home page Giter VIP logo

smtpapi-nodejs's Introduction

SendGrid Logo

Test and Deploy npm MIT licensed Twitter Follow GitHub contributors

This node module allows you to quickly and more easily generate SendGrid X-SMTPAPI headers.

Announcements

All updates to this module are documented in our CHANGELOG.

Table of Contents

Installation

Prerequisites

  • Node.js version 4, 5, 6, 7, 8, 10, 12, 14, or 16
  • The SendGrid service, starting at the free level

Environment Variables

Update your environment with your SendGrid credentials. (if you will be sending via nodemailer or other SMTP transport)

echo "export SENDGRID_USERNAME='YOUR_USERNAME'" > sendgrid.env
echo "export SENDGRID_PASSWORD='YOUR_PASSWORD'" >> sendgrid.env
echo "sendgrid.env" >> .gitignore
source ./sendgrid.env

The following recommended installation requires npm. If you are unfamiliar with npm, see the npm docs. Npm comes installed with Node.js since node version 0.8.x, therefore, you likely already have it.

Install smtpapi-nodejs and its dependencies:

npm install smtpapi

Dependencies

Quick Start

var smtpapi = require("smtpapi");
var header = new smtpapi();
header.addTo("[email protected]");
header.setUniqueArgs({ cow: "chicken" });
console.log(header.jsonString());

Usage

How to Contribute

We encourage contribution to our projects, please see our CONTRIBUTING guide for details.

Quick links:

About

smtpapi-nodejs is maintained and funded by Twilio SendGrid, Inc. The names and logos for smtpapi-nodejs are trademarks of Twilio SendGrid, Inc.

Support

If you need help with SendGrid, please check the Twilio SendGrid Support Help Center.

License

The MIT License (MIT)

smtpapi-nodejs's People

Contributors

akram-rameez avatar awwa avatar brandonmwest avatar eddiezane avatar eric1iu avatar eshanholtz avatar gr8shivam avatar jeffgerlach avatar limianwang avatar lvarayut avatar mbernier avatar mell0kat avatar mgingras avatar motdotla avatar mptap avatar myzeprog avatar nocategory avatar nquinlan avatar prempalsingh avatar pushkyn avatar rafaelverger avatar rakatyal avatar robertacosta avatar rohitdaryanani avatar rpaterson avatar shwetha-manvinkurke avatar thepriefy avatar thinkingserious avatar twilio-ci avatar twilio-dx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

smtpapi-nodejs's Issues

Add a USAGE.md file

Usage files are really nice when they exist in a repo, because it makes it really obvious where to look for information about how to use this tool. It can be frustrating when you expect this file to be there and it's not.
Please add a USAGE.md file, you can see an example of this
here

Please make sure you modify the file for this repo (hint: Most of this information should be in the README file)

Add our Developer Experience Engineer career opportunity to the README

Issue Summary

The role of Developer Experience Engineer just became available and we want to announce it in the README. Here is the copy:

If you're a software engineer who is passionate about #DeveloperExperience and/or #OpenSource, this is an incredible opportunity to join our #DX team as a Developer Experience Engineer and work with @thinkingserious and @aroach! Tell your friends :)

Acceptance Criteria

  • The above announcement is added to the Announcements section of this README

Improve esdoc's coverage report

Issue Summary

Adding documentation is a great way to save yourself and other developers time when they are looking at code to understand what was coded or when they are troubleshooting an issue.

Steps to Reproduce

  1. clone this repo git clone https://github.com/sendgrid/smtpapi-nodejs.git
  2. run npm install
    a. If #50 is not complete or merged yet, npm i [email protected] esdoc esdoc-coverage-plugin
  3. run ./node_modules/.bin/esdoc
  4. Open the coverage.json file that was generated in the docs directory
  5. Find files that need more docs coverage and add it in!

Not receiving HTTP POST containing a JSON array Data in webhook url

Issue Summary

Hi,

I tried to implement smtpapi API with setup of webhook but unfortunatly mails are delivering to users but data are not receiving intop webhook url.

Here is my code to send mails:-

var smtpapi   = require('smtpapi');
var header    = new smtpapi();
header.addTo(email);									
header.setUniqueArgs({'unique_id': "123"});
var headers={'X-SMTPAPI':JSON.stringify(header)};
var settings  = {
	host:config.email_host_name,
	port:25
};
var smtpTransport1 = nodemailer.createTransport(settings);
var email="[email protected]";
var subject="Test SMTPAPI";
var out="<b>Hello world</b>";
var mailOptions = {	
  to :email,	
  from:config.email_from_addr,
  subject :subject,					
  html:out,
  headers:  headers
};
smtpTransport1.sendMail(mailOptions, function(error, response) {
	if(error) {
		console.log("send mail error: "+error);							
	 }else {
		console.log("Message sent response:- "+util.format("%j",response));
	 }
});

I did setup webhook url as "https://npd.nowconfer.com:5000/calendar/sendgrid_webhook" in mail settings page.
can you figure out what is happening wrong here?

Category List

is there a limit to the number of categories I can add?
currently I have 17 categories, and im adding new ones using :

api_user=USERNAME&api_key=KEY&category=CATEGORY

I receive success message , but the category wont show in the query from
the link you provided on the other issue (https://sendgrid.com/docs/API_
Reference/Web_API/Statistics/index.html#-Category-List)

(p,s I've also tried adding the category via
https://sendgrid.com/docs/API_Reference/Marketing_Emails_API/categories.html
same result : getting success msg, but the category wont appear)

Hacktoberfest: SendGrid Current Status

SendGrid DX team current status:

  • Wow
  • OMG
  • THANK YOU

Hacktoberfest 2017 has completely blown us away. We have had over 900 pull requests from over 300 contributors all in the last 30 days. That is more PRs than we normally get in 2 years!
We are actively working to review, comment, and/or merge as many PRs as we possibly can as quickly as we can.

We are currently working on “intaking” all the PRs that have come in, oldest first (we have about 400 remaining to go through). We are making sure that each PR we review is one we have a chance of merging - there have been a couple spammy items that came through. Due to the massive influx of requests so far, @thinkingserious and @mbernier have been working nights and weekends all month just to keep up! We’re not even mad, this is amazing!

Hey, that’s great for you - but what about my shirt!

If you have signed the CLA before 11/1, but haven’t had a PR merged yet, do not despair! We know we are behind on even just commenting on every PR to show you that we received it (something we typically do). If you submitted a mergeable (non-spam, actually adds value to the project) PR during October 2017, we will grant access to this page to redeem your shirt, sticker, and hacker pin. Next year, we will be sure to communicate this information sooner. We are sorry for any confusion we have caused. We appreciate those of you who have reached out to find out what’s going on!

What can I do to help move things along?

Have you signed the CLA yet?
We can only merge items from contributors who signed the CLA

Can you help another contributor?
If you can identify potential problems, add suggestions, or even leave a comment with your review of another PR (Looks good to me! Or I approve this change), that would help us review those PRs much faster, making it easier to get to your PR.

Do you even write tests, friend?
If you see a place where we could have a test to validate a piece of functionality, add it in. We know We know! It’s just another PR we have to review and merge. You’re right, it is! However, the more tests we have, the earlier our CI tool can catch issues, saving us a review as well as back and forth time.

@akram-rameez, @casche, @lvarayut, @mptap, @thepriefy

Add unittest to check for specific repo files

This repo should have the following list of files included:

  • ./Docker or docker/Docker
  • ./docker-compose.yml or ./docker/docker-compose.yml
  • ./.env_sample
  • ./.gitignore
  • ./.travis.yml
  • ./.codeclimate.yml
  • ./CHANGELOG.md
  • ./CODE_OF_CONDUCT.md
  • ./CONTRIBUTING.md
  • ./.github/ISSUE_TEMPLATE
  • ./LICENSE.md
  • ./.github/PULL_REQUEST_TEMPLATE
  • ./README.md
  • ./TROUBLESHOOTING.md
  • ./USAGE.md
  • ./USE_CASES.md

This PR is only asking for tests of the existence of these files, if the files do not exist when you run the tests - do not worry about the tests not passing. We will identify this and create a new PR for the issue.
Thank you!

Update .md files for SEO-ness

We received an awesome PR for #hacktoberfest on our ruby library
We would love to see the same thing on the README in this repo as well.
Please replace the "-" with "_" in README, CONTRIBUTING, USE_CASES, USAGE files.

Thanks and happy Hacktoberfest!!

Require conformance to style standards

Issue Summary

In the CONTRIBUTING.md file there is a section on Style Guidelines & Naming Conventions. Please review and implement a check in Travis CI. If there are any style errors, either fix or create a rule to exclude the error.

Before writing any code, we suggest you review our CONTRIBUTING.md file and propose your solution for discussion here in the comments. Thank you!

Aceptance Criteria

  • TravisCI checks that the code conforms to our Style Guidelines & Naming Conventions as defined in our CONTRIBUTING.md file
  • tests pass locally, in Travis CI and using Docker

Auto-generate the release notes upon release

Issue Summary

For every release, we hand craft the release notes on GitHub, now we would like to automate this process. Please see the existing release notes for an example. The contents of the release notes are generated from the CHANGELOG.md file. Here is the documentation for updating the release notes via the GitHub API.

Acceptance Criteria

  • A script, which when run, creates a release note update based on the last deployed release

Add a unittest to check the license.md file date range

The end year in the license file should be "this year" and this should be checked on every run of the tests. If the end year is no correct, fail the test.
example:

Copyright (c) 2012-2016 SendGrid, Inc.
It is 2017, so this should be:
Copyright (c) 2012-2017 SendGrid, Inc.
and the test should fail.
--done

Nodejs

Issue Summary

A summary of the issue and the environment in which it occurs. If suitable, include the steps required to reproduce the bug. Please feel free to include screenshots, screencasts, code examples.

Steps to Reproduce

  1. This is the first step
  2. This is the second step
  3. Further steps, etc.

Any other information you want to share that is relevant to the issue being reported. Especially, why do you consider this to be a bug? What do you expect to happen instead?

Technical details:

  • smtpapi-nodejs Version: master (latest commit: [commit number])
  • Node.js Version: 4.x.x

Document new Git workflow in CHANGELOG.md

Issue Summary

We want to update our git workflow to function more like Gitflow. We need to update the CONTRIBUTING.md file and PULL_REQUEST_TEMPLATE to direct contributors to fork/branch off the development branch and to merge their PRs with the development branch. Once this issue is complete, we will be creating the development branch and making that branch the default. This is part of a larger strategy to execute releases for this SDK on a predictable cadence.

Acceptance Criteria

  • Update CONTRIBUTING.md documentation, explaining the process of forking and branching off the development branch and submitting PRs agains the development branch.
  • Update PULL_REQUEST_TEMPLATE with the same addition to the CONTRIBUTING.md documentation.

Add esdoc support

Issue Summary

Creating local documentation can be super helpful

  1. Force a version of chai and install esdoc and coverage plugin
npm i [email protected] esdoc esdoc-coverage-plugin
  1. In the root dir, create .esdoc.json with the following:
{
    "source": "./lib",
    "destination": "./docs",
    "plugins": [
      {
        "name": "esdoc-coverage-plugin", 
        "option": {
          "enable": true,
          "kind": ["class", "method", "member", "get", "set", "constructor", "function", "variable"]
        }
      }
    ]
  }
  1. Update .gitignore by adding docs to the list of files to ignore
  2. Look at this PR and make the same changes to the files here in smtpapi-nodejs as were made to CONTRIBUTING and USAGE in sendgrid-nodejs

Category List

hello,
Trying to use your API for getting a list of all categories for my account
but it seems even the example at the web API page gives wrong results:

the code :
curl -X POST https://sendgrid.com/api/stats.get.json -d api_user=[email protected] -d api_key=XXXXXXXX

should " Retrieve a list of all the categories used in your account." (quote)
the actual result is :

[
{
"delivered": 0,
"unsubscribes": 0,
"invalid_email": 0,
"bounces": 0,
"repeat_unsubscribes": 0,
"unique_clicks": 0,
"blocked": 0,
"spam_drop": 0,
"repeat_bounces": 0,
"repeat_spamreports": 0,
"date": "2014-11-13",
"requests": 0,
"spamreports": 0,
"clicks": 0,
"opens": 3,
"unique_opens": 1
}
]

How do I get a list of all active categories on my account?

Create first time contributor documentation

Issue Summary

Our open sourced documentation has a great first time contributor page that we wish to duplicate here.

Acceptance Criteria

  • We have a file in the root directory called first-timers.md or similar that helps a first time contributor make their first PR (please use our CONTRIBUTOR.md file for inspiration as well as this page)
  • We provide a link to tasks with the labels "difficulty: easy" and "status: help wanted" (example query) to all the repos listed here, please scroll to the bottom.

Implement auto-deploy to package manager

Issue Summary

When all tests on the master branch pass in Travis CI, we would like to auto-deploy the release to the package manager.

Before writing any code, we suggest you review our CONTRIBUTING.md file and propose your solution for discussion here in the comments. Thank you!

Aceptance Criteria

  • when Travis CI passes all tests on the master branch we auto-deploy to the package manager
  • the version is determined by the CHANGELOG.md

There are tests that probably shouldn't exist

Issue Summary

In file tests/main.js there are some tests scenarios that tries to ensure the existence of some files but some of them were never created in this repo.

Steps to Reproduce

  1. Clone the repo
  2. npm install
  3. npm test

Those failing scenarios probably shouldn't exist as well.

Auto-generate the CHANGELOG.md file upon release

Issue Summary

For every release, we currently hand craft a CHANGELOG.md update, now we would like to automate this process. Please see the existing CHANGELOG.md for formatting structure.

Acceptance Criteria

  • A script, which when run, creates a CHANGELOG.md update based on any merged PRs since the last release.

Create a Use Cases Directory

Due to the success we have seen from hacktoberfest, we are seeing more people create use cases. This is amazing!
We want to make sure that everyone can find them. Please help us to break up this file and make it easier to read and manage:

  • Create a Use Cases Directory
  • Put a README.md in this directory
  • Make a file in the new directory for each individual Use Case from USE_CASES.md, copy the content to this file
  • For each file you've created, link to it from the README you created
  • Organize the links in the README by type
  • Make sure the names of the files you created are related to the Use Case
    Thank you!

Add a .env_sample file

Our preference is that users have an environment file when using the SendGrid API, because it is less likely that someone would commit their credentials to github.

Please make a couple changes:

  • make a .env_sample file that contains: export SENDGRID_API_KEY=''
  • make (or add) a .gitignore file and include .env
  • add instructions to the README file about how to copy .env_sample to .env and add the API Key

Docker build of this repo

Issue Summary

It is really nice to be able to develop locally inside a docker container! Please dockerize this repo!

  • You can probably use the Dockerfile for sendgrid-nodejs
  • Please setup docker-compose to use a local volume for the library files (this is currently different from sendgrid-nodejs)
  • Please add information to the README and USAGE files about how to startup the container

A docker whale walked into a bar - smtpapi-nodejs & docker

Issue Summary

It is really nice to be able to develop locally inside a docker container! Please dockerize this repo!

  • You can probably use the Dockerfile for sendgrid-nodejs
  • Please setup docker-compose to use a local volume for the library files (this is currently different from sendgrid-nodejs)
  • Please add information to the README and USAGE files about how to startup the container

addBcc

I'm use the sendgrid's a for node, but if I need send mails but needed occult others people who are receiving the email. Normally we using BCC.
I think in add the functionality to the code, but in smtpapi I don't see a mention to bcc, It's better if I implemented this only in the sendgrid's node api?

Space added in substitution value

Issue

So I am following the example code in the repo and attempt to send email to multiple recipients using multiple substitution values like so:

header.setTos(['[email protected]', '[email protected]', ....);
header.addSubstitution('{{token}}', ['...', '...', '1fccc78932657d7d024521eee12a90', '...']);

The emails are being delivered successfully but the tokens are sometimes set randomly with space around it (e.g. "1fccc78932657d7d024521 eee12a90")

Checked the actual payload being sent to the server and I can verify that the token values do not contain spaces.

Technical details:

  • smtpapi-nodejs Version: 1.3.1
  • Node.js Version: 6.x.x

Add a .codeclimate.yml file to this repo

It is possible to configure how CodeClimate looks at a repository.
These Docs explain how this is done. Please create an appropriate .codeclimate.yml for this repo. It should test the main language of the repo and run tests.

Not Getting Substitutions in "BCC or CC"

if have been using transaction templates of sendgrid to send mails. We too have substitutions in mail templates. I am setting {CC and BCC} in every mail but not getting substitutions there in CC'ed mails.

Add/Update Badges on README

Similar to what was done on the SendGrid node README:

  • put the logo at the top of the list
  • Add License like so
  • make sure the other badges are available like so:
![SendGrid Logo](https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png)

For the following, make sure the correct repo is linked!
For email notifications, you can change the "nodejs" to the language of this repo (e.g. java, python, ruby, php, csharp, go, etc)

[![BuildStatus](https://travis-ci.org/sendgrid/sendgrid-nodejs.svg?branch=master)](https://travis-ci.org/sendgrid/sendgrid-nodejs)
[![Email Notifications Badge](https://dx.sendgrid.com/badge/nodejs)](https://dx.sendgrid.com/newsletter/nodejs)
[![npm](https://img.shields.io/npm/l/express.svg)]()
[![Twitter Follow](https://img.shields.io/twitter/follow/sendgrid.svg?style=social&label=Follow)](https://twitter.com/sendgrid)
[![GitHub contributors](https://img.shields.io/github/contributors/sendgrid/sendgrid-nodejs.svg)](https://github.com/sendgrid/sendgrid-nodejs/graphs/contributors)

Thank you and happy #Hacktoberfest!!

Setting a batch id results in emails not being sent

Hello. I'm leveraging the smtpapi, and when I set a batch id via:

smtpHeader.setBatchId(campaign._id); // e.g.: "b57a2545-6cb4-4f37-a840-b8095390f223"

along with setSendAt(), I never receive the email. If I remove the batch id, I do.

are there limits on how many characters I can set the batch id to?

How do I use X-SMTPAPI with mail helper?

Is it possible to use this library with helper class (const helper = require('sendgrid').mail) ?

I tried many ways but no lucky. For example:
mail.addHeader(new helper.Header('X-SMTPAPI', '{"to": ["[email protected]"]}'));

and:
const smtpapi = require('smtpapi');
var header = new smtpapi();
header.addTo('[email protected]');
var headers = { 'X-SMTPAPI': header.jsonString() };
var request = sg.emptyRequest({
method: 'POST',
path: '/v3/mail/send',
body: mail.toJSON(),
headers,
});

Sending email's with generated batch_id not working

Hello,

I am creating a batch id using https://api.sendgrid.com/v3/mail/batch and it is returning a valid batch_id.

I am then sending a message with batch_id:
...
msg.batch_id = batch_id;
msg.send_at = [FUTUREDATE]
await sgMail.send(msg);
...

After sending, If I then try to validate the batch_id with /mail/batch/{batch_id}, it does validate.

However, if I try /user/scheduled_sends and it returns an empty array. If I try and cancel running: https://api.sendgrid.com/v3/user/scheduled_sends/{batch_id} it returns:
{
"errors": [
{
"field": null,
"message": "batch id not found"
}
]
}

The email is sent at the time it is scheduled to go out, but because I can't validate the batch_id, I am unable to cancel or pause.

Am I missing something, or does this seem like the correct way to handle this.

I have updated to the latest package: @sendgrid/mail: ^7.4.2,

Thanks!

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.