Forum Academy Marketplace Showcase Pricing Features

How to set up Inbound Emailing with Postmark’s Inbound Processing

If you want your users to be able to reply to transactional emails and get their replies into your platform (e.g. as a message, etc.) you can use Postmark’s Emailing API to set up inbound parse.

Before using Postmark, I tried Sendgrid’s inbound parse and researched a variety of options, but decided to go with Postmark due to great pricing, great documentation and a good parser engine that cuts old email threads automatically before posting the content to your app’s endpoint.

Here it goes:

1) Sign up for Postmark and setup a new server. Call it “inbound parser” or whatever you want to name it.

image

2) Create a new backend workflow in your app. This should be a public endpoint. Check the setting below. Call it whatever you want.

image

3) Go to Settings / API and copy your apps public endpoint link.

4) Go back to your workflow, click “Detect Data”

5) Go to your server’s settings page in Postmark and paste the public endpoint link into the webhook field. Click “Check” (make sure your app is waiting for the call aka the “Detecting Request Data” dialogue is open). Postmark will now do a test call to the public endpoint in your app. If it worked out, it will return with a status code of 200. Click “Save Changes”

6) Back in your app, you will now see the Request Data overview dialogue. Click “Save”. Awesome! You just setup inbound parse into your app.

image

7) You can now send emails to Postmark’s inbound email address to test your connection (find it on your servers settings page). Any email sent to this address will be posted to your endpoint. You should set up inbound domain forwarding in Postmark. I won’t explain this, as it’s documented very well within Postmark.

8) Now you can do all sorts of fun stuff in the app with the data from Postmark, e.g. create messages, etc.

image

Things to consider:

A) I recommend to set up an “intermediary” data type, that saves the most important info from the call your endpoint receives. Different email engines send data in different formats to Postmarks, so e.g. “Stripped Text Reply” might not always work. You could call this “Parse_Data” and save things like the inbound emails from, to, html reply body, stripped text reply body, text body, etc. This is important to not loose data, when something goes wrong.

B) It’s possible to take attachments from incoming emails and save them in the app. I will explain how to do this below.

C) To make sure incoming emails are routed to the right user, conversation, whatever you want to use the data for, you should assign individual keys to each user, message stream, etc. in your app and set them as the reply_to address when you send outbound emails for conversational transactional emails.
We solved by setting outbound email reply_to email addresses as INDIVIDUALKEYUSER12DIGITS_INDIVIDUALKEYANOTHERTHING12DIGITS@yourappdomain.com (e.g. [email protected]).
When a user replies to an email, the app will cut the reply_to information from the Postmark call using find&replace and truncated_to and do a search for the right user and message stream.

Bonus: create files from inbound email attachments

1) Create a new datatype. I call this “parsefile”. “message” is the message in my database (another datatype) that I want to attach the files to.

2) Create a new backend workflow. I call this “create_attachments”

3) This is the workflow (in the right order) that I set up to create attachments. You will need the plugin “EZ Uploader” to decode the Base64 attachments.

Step 1) Create a new “parsefiles”

Step 2) Decode the base64 string attachment using the EZ Uploader plugin

Step 3) Use the newly created file and attach it to whatever you want (e.g. a message). The file can be accessed like this
image

Step 4) Add a step in your inbound parse workflow where you schedule this backend workflow on the list “Request Data’s attachments” (which is a basically a list base64 encoded strings which are your attachments)

Feel free to ask questions! Hope this helps

22 Likes

I keep getting a 404 error from Postmark, post the initial test, it’s driving me crazy. Have retraced my footsteps many times. Any ideas would be massively appreciated? Thank you!

Did you initialize the endpoint? The URL you put into postmarks field here, is not the initialisation webhook url. You need to click on “detect data” in this popup first and then copy and paste the URL given there into postmark. Afterwards it should work and then you can replace that URL with your actual endpoint url.

Edit: just realised I skipped that step in the initial explanation. Sorry for any grey hair this may have caused!

1 Like

You sir are a gent, thank you very much! Have a great festive period!

Hello @maru !

This is a great post ! Thanks a lot ! It works like a charm !

But I have a question : How do you deal with multiples attachments ?

Do you have any idea why I have error code 401?

Thanks

Can you specify where and under what circumstances you get a 401 error?

Sending multiple attachments should also work fine, where are you stuck or what error are you getting?
Sorry for the late reply btw

After pressing the detect button on bubble, when I check the address at postmark… As in the image attached…

is the initialize popup open in the bubble editor? If it is not open, bubble is not waiting for data on this endpoint and will return a 401. After the endpoint has been initialized, you have to switch the initializition-endpoint URI with the URI that should be used for production. Hope that solves it!

Thank you very much for your patience.
It is open and I have switched the URL for the one appearing on the popup… same message :frowning:

I’m afraid, that I cannot replicate the issue. Everythings works fine for me, when I follow the above steps.

Make sure there are no typos in the URI, the backend workflow is exposed as public workflow and the “Detect Request Data” popup is open and listening for data posted to this endpoint. It’s most likely an authentication issue (hence the 401) - do you have workflow APIs enabled under settings? Maybe try to set the workflow settings to “can be run without authentication”.

Hello Maru,

thanks, I solved the problem :slight_smile:

Best regards,

Jeremy