PubNub Integration

SendGrid: Transactional Email

Alerts & Notifications

Alerts & Notifications

Last Updated:



Ian Jennings

SendGrid DocumentationGetting Started Tutorial

Send transactional emails triggered by user action

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.


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: ''

All you need to do is configure the api_userapi_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": "",
    "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": "",
    "toname": "Ian Jennings",
    "subject": "hey there from a block",
    "text": "hello world"

Feedback & Support

Need help? Contact PubNub Support.

Talk to an expert

Contact Sales