1.0.10 • Published 12 months ago

@scrrum-labs/sendgrid-inbound-parser v1.0.10

Weekly downloads
-
License
ISC
Repository
-
Last release
12 months ago

sendgrid-inbound-parser

Configuration

  1. Navigate to the MX Records page on your hosting provider’s website. If you’re unsure who your hosting or DNS provider is, please contact your website administrator.
  2. Create a new MX record for the subdomain (e.g. parse.yourdomain.com) you want to process incoming email.
  3. Assign the MX record a priority of 10, and point it to the address: mx.sendgrid.net. It should look something like this:
10 mx.sendgrid.net.
  1. From your SendGrid Dashboard click Settings, and then click Inbound Parse. You are now on the Inbound Parse page.
  2. Click Add Host & URL. (The URL must be accessible from the public web.)
  3. Enter the subdomain (for example, "parse") and select the authenticated root domain for your receiving domain. Enter the public URL where you would like the parsed data to be POSTed.
  4. Click Save.

Installation

$ npm install --save @scrrum-labs/sendgrid-inbound-parser

Usage

At your hosted url

const sg = require("@scrrum-labs/sendgrid-inbound-parser");

export const storeEmail = functions.https.onRequest(async (request) => {
              const subject = sg.getSubject(request.body)
              const body = sg.getBody(request.body)
              const attachment = sg.getAttachment(request.body)
              });

Methods

getBody(data){} // It will return whole body: String, 
example: "Test Body" 
getTo(data){} // It will return email ID & name of receiver: Array of object, 
example: [{email:"xyz@scrrum.com", name:"scrrum"}]
getFrom(data){} // It will return email ID & name of sender: Array of object, 
example: [{email:"xyz@scrrum.com", name:"scrrum"}]
getSubject(data){} // It will return subject of incomming email: String, 
example: "Test Subject" 
getSenderIP(data){} // It will return IP address of incomming email: String, 
example: "90.92.80.92.02" 
getAttachmentsNumber(data){} // It will return number of attachments: Number, 
example: 2
getAttachmentInfo(data){} // It will return info of attachments: JavaScript object, 
Example: 
{
  "attachment1": {
    "filename": "46568986193797146.csv",
    "name": "46568986193797146.csv",
    "charset": "UTF-8",
    "type": "text/csv",
    "content-id": "f_lhj3sxzx1"
  },
  "attachment2": {
    "filename": "react.png",
    "name": "react.png",
    "type": "image/png",
    "content-id": "f_lhj3sxzq0"
  }
} 
getAttachment(data){} // It will return attachments: Array of object, 
example: [{content:"",contentType:""}] 
getHtmlBody(data){} // It will return whole html body : String, 
example: "<html><body>Test Body</body></html>"
1.0.10

12 months ago

1.0.9

12 months ago

1.0.7

12 months ago

1.0.6

12 months ago

1.0.5

12 months ago

1.0.4

12 months ago

1.0.3

12 months ago

1.0.2

12 months ago

1.0.0

12 months ago