External APIs

SendGrid: Transactional Email

Send transactional emails triggered by user action
Back to BLOCKS

About SendGrid: Transactional Email

SendGrid offers a number of services for sending, tracking and managing email.

The SendGrid block allows you to send the contents of a PubNub message as an email, or build in a event-based trigger to send the email after a transaction is complete, or after some other event has happened.

Try it Now
Categories:
External APIs External APIs
Internet of Things
Internet of Things
Chat & Social
Chat & Social
Triggers & Notifications
Triggers & Notifications
Last Updated:
20160729 at 18:33:17
Author:
Ian Jennings

Walkthrough

Send an email by PubNub publish! This block will send an email every time a message is published on a particular channel. It uses SendGrid as an email provider and a single XHR request to interact with SendGrid's API.

{
  api_user: 'your_user',
  api_key: 'your_pass',
  from: 'text@example.com'
}

All you need to do is configure the api_user, api_pass and from values within the xhr.fetch call. The variable api_user is your SendGrid username, and api_pass is your SendGrid password. If you don't have an account, just header over to SendGrid to sign up. Don't forget to change the from value to whatever address you'd like the email to appear as sent by.

Then, publish a message over the PubNub block channel and supply the following parameters in an object.

{
    "to": "target@email.com",
    "toname": "Your Name",
    "subject": "Email Subject",
    "text": "Email Body"
}

This demo block will automatically add the entire contents of the published body to the email message for debugging purposes.

Publish An Email Config

Publish a message with the target's email, name, and message. An email will be sent to the address supplied in the message.
{
    "to": "ian@pubnub.com",
    "toname": "Ian Jennings",
    "subject": "hey there from a block",
    "text": "hello world"
}
 

Try PubNub Today

Connect up to 100 devices for Free