arisAlexis / landing-subscriber-sendgrid

Landing page backend API endpoint working with Sendgrid

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

landing-subscriber-sendgrid

Landing page backend API endpoint working with Sendgrid

Intro

This helps you to keep the subscribers on a simple landing page on a sendgrid contacts list for later use.
It solves the problem of hosting your website statically without any scripts running to write the emails to databases or text files.

Usage

git clone this repo
npm i
mkdir config; nano config/default.json

The default.json file should have these:

{
  "port": "my_port_number",
  "sendgridKey": "your_secret_sendgrid_api_key"
}

You can find your list number by going to the sendgrid iface and seing the viewList link

Then you need to install the letsencrypt certs (tutorials available online) and make a folder named keys under the root and paste there privkey.pem, cert.pem and chain.pem.

Then you can use your favorite daemon such as PM2 and run pm2 start js/server.js.

From your webpage you need to hit the endpoint eg. with jQuery:
$.get('https://your_host:8080/fn/subscribe?list=your_list_number&email='+$('#emailField').val());

About

Landing page backend API endpoint working with Sendgrid

License:MIT License


Languages

Language:JavaScript 100.0%