Need to store all details from Sent Mail like Subject, Body and sent To and From, Message, etc. in postgresql Log table

Describe the problem/error/question

I Need to store all details from Sent Mail and Twilio Messages like Subject, Body and sent To and From, Message, To Phone Number etc etc in postgresql Log table. This is just like logging the details in different tables after the mails and messages are sent.

What is the error message (if any)?

I need a way to capture all those details and then store it in Postgresql table. As Output of Send Mail node.

Please share your workflow

And below are the Highlighted details that I need to capture.

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version: n8n Version 0.209.4
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Desktop app
  • Operating system: - Windows 10

Hi @SWAPNIL_NANDANWAR, I am not sure I understand the problem here. Are you running into any issues with simply adding a Postgres node after your Send Email (or Twilio) node inserting the data you’re looking for? If so, can you share your workflow and the exact error you’re seeing?

I am asking because from quickly testing this on my side this appears to work fine.

Hi @MutedJam ,

Here I want to save the Send Mail Node’s details like Text (i.e Body), Subject, To Email for every mails as a log in postgresql table.
In Twilio it works fine as we get different details like Body, from , to etc as the output of the Twilio node. But same doesn’t happen in case of Send Mail node. I am attaching screen shots from Twilio and Send Mail nodes.
I am good with Twilio output but don’t know how to get details from Send Mail node.
There is No Error, I just need a way to capture few details as logs in our table.

Twilio which is fine. I have mentioned with arrows and Highlights for the details that I get which is wat I needed -

But, I do not get similar type of details in output of Send Mail Node. I have rounded details that I need in red mark -

Could you please help me with this.
Let me know if you need any more information.

Hi @SWAPNIL_NANDANWAR, seeing you have shared only a screenshot of your workflow I don’t quite know what your Code node returns or how your database table looks like.

But it seems to me you can use a Set node to simply read the values you’re looking for from your Code node into the right columns, then insert your data into your Postgres table:

I’ve tested this just now and it’s working fine:

Hope this helps :slight_smile:

On a separate note, you might want to consider switching from using n8n desktop to using the Docker version of n8n (as the desktop version has been deprecated and won’t receive further updates).

1 Like

Thank you @MutedJam for the information.

Could you please let me know how do I upload my whole workflow that would help you in more details as I do not see the output like {{ $node[“Code”].json[“subject”] }} and {{ $node[“Code”].json[“text”] }} in Set node, when I connect it to Send Mail node. Attaching the screenshot for the same -

I do not see the output like {{ $node[“Code”].json[“subject”] }} and {{ $node[“Code”].json[“text”] }} in Set node, when I connect it to Send Mail node

Hi @SWAPNIL_NANDANWAR, you might need to write these expressions manually in your Set node. Alternatively, simply select the node in my example workflow here on the forum, press Ctrl+C to copy it, and finally press Ctrl+V in your own n8n canvas to paste it.

This also works the other way round, you can select your workflow on the right in your n8n canvas, then copy and paste it here on the forum (make sure you remove anything confidential though).

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.