Mailer - Github

Sends the latest post from the RSS feed to the Netlify subscribers

dependenciesversion commit license

Prerequisites

Git and Node.js will need to be installed. You will need a decent Code Editor. And also a decent understanding of the Command Line Interface. (Powershell works fine on Windows)

Setup

This was designed for my Netlify Blog that had an RSS feed. It grabs the subscriptions from the blog and emails the subscribers about my most recent post.

To create the contact form use this snippet:

<form name="subscribe" method="POST" data-netlify="true">
<p>
<label>Your Name: <input type="text" name="name" minlength="3" required/></label>
</p>
<p>
<label>Your Email: <input type="email" name="email" required/></label>
</p>
<p>
<button type="submit">Send</button>
</p>
</form>

To download the code use this command:

git clone https://github.com/andrejarrell/Mailer.git mailer

Open the directory and install the required dependencies.

cd mailer
npm i

Create a file named .env

.env
# You can create a token here:
# https://app.netlify.com/user/applications/personal
NETLIFY_TOKEN=
# Most SMTP providers offer generous free tiers (I use gmail)
SMTP_HOST=
SMTP_USER=
SMTP_PASS=
# The current domain of your site (ex: blog.andre.gg)
SITE_DOMAIN=
# The email you want to send as and for people to reply to
YOUR_EMAIL=

Fill in the required settings (no quotes needed in .env file)

Run

node index.js

Email

Example of what the email looks like when it is sent

API

get

https://api.netlify.com/api/v1/sites/:site/submissions
Get form submissions from Netlify site
Request
Response
Path Parameters
site
required
string
Site API Id or site domain
Query Parameters
access_token
required
string
Access token for API
200: OK
[
{
"number": 1,
"title": "Andre Jarrell",
"email": "[email protected]",
"name": "Andre Jarrell",
"first_name": "Andre",
"last_name": "Jarrell",
"company": null,
"summary": "<strong>Andre Jarrell</strong> ",
"body": null,
"data": {
"name": "Andre Jarrell",
"email": "[email protected]",
"ip": "99.132.88.296",
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36",
"referrer": "https://blog.andre.gg/"
},
"created_at": "2019-03-31T07:48:56.548Z",
"human_fields": {
"Name": "Andre Jarrell",
"Email": "[email protected]",
},
"ordered_human_fields": [
{
"title": "Name",
"name": "name",
"value": "Andre Jarrell",
},
{
"title": "Email",
"name": "email",
"value": "[email protected]",
}
],
"id": "5cajh0e87be0e66e7ja888f1",
"form_id": "5cac708s35hd450009309g05",
"site_url": "http://blog.andre.gg",
"form_name": "subscribe"
}
]