node.jssendgridemail-forwarding

Forwarding Inbound Emails sendgrid


I have a node.js app that uses the sendgrid api to send emails. I want people to be able to reply to those, and then forward the reply to another email. E.G: bleep@bleep.com sends automated email to blop@blop.com.

blop replies, "hello", and I want the email containing "hello" to be forwarded to another email, such as recieving@bleep.com. (Or something like that) I have done some research and all I can find is using parse webhooks (whatever those are :] ) to send POST requests to a server when an inbound email is detected.

What I dont understand is why (if you can do that), you cant simply forward it to another email.

If there is no way to forward them, is there some node module that could accept the POST request and then forward it? Thank you in advance!


Solution

  • Use the "reply_to" from SendGrid.

    https://sendgrid.com/docs/for-developers/sending-email/api-getting-started/#send-your-email-using-the-api

    curl --request POST \
    --url https://api.sendgrid.com/v3/mail/send \
    --header 'Authorization: Bearer <<YOUR_API_KEY>>' \
    --header 'Content-Type: application/json' \
    --data '{"personalizations":[{"to":[{"email":"john.doe@example.com","name":"John Doe"}],"subject":"Hello, World!"}],"content": [{"type": "text/plain", "value": "Heya!"}],"from":{"email":"sam.smith@example.com","name":"Sam Smith"},"reply_to":{"email":"sam.smith@example.com","name":"Sam Smith"}}'
    
    1. Set the reply_to to "a@example.com".
    2. "a@example.com" is a real email address you own and control, not part of SendGrid. Setup that account to forward emails being sent to it to automatically forward to "b@example.com".