Skip to content
How to parse .eml f...
 
Notifications
Clear all

How to parse .eml files in callin.io

13 Posts
3 Users
0 Reactions
4 Views
Hellboy
(@hellboy)
Posts: 7
Active Member
Topic starter
 

Hello Everyone,

I'm new to callin.io and have no prior coding experience.

My goal is to create an AI agent (Chat Bot) that functions as a Cyber Security Analyst to examine malicious emails.

I'm currently in the early stages. As you can see in the screenshot below, my workflow offers the user two options: paste the raw email headers directly into the chat or upload an .eml file for analysis. My 'If' node correctly identifies the raw email headers and the .eml file attachment. However, I'm stuck at the Code node because I'm unable to parse email headers from the .eml file. I've tried several methods without success. Could someone please provide guidance on how to proceed?

I attempted to use the open-source community node https://nodemailer.com/extras/mailparser/ , but I'm encountering an error.

I installed it using npm install mailparser within the Docker container where my callin.io instance is hosted.

Any assistance would be greatly appreciated.

 
Posted : 28/07/2025 1:43 am
jabbson
(@jabbson)
Posts: 40
Eminent Member
 

Hello, hope you're doing well. How did you manage the installation?
I attempted it myself, and it seems to be working correctly.

docker exec -it --user root callin.io /bin/sh
cd .callin.io
npm install -g mailparser

And then:

 
Posted : 28/07/2025 2:02 am
Hellboy
(@hellboy)
Posts: 7
Active Member
Topic starter
 

Thank you for your assistance, I really appreciate your support.

I am still encountering an error after trying the method you suggested. Please review the screenshots below. I have also restarted the container after installing mail parser.

{
"errorMessage": "Cannot find module ‘mailparser’ [line 1]",
"errorDescription": "VMError",
"errorDetails": {},
"n8nDetails": {
"nodeName": "Code1",
"nodeType": "n8n-nodes-base.code",
"nodeVersion": 2,
"n8nVersion": "1.103.2 (Self Hosted)",
"binaryDataMode": "default",
"stackTrace": [
"VMError: Cannot find module ‘mailparser’",
" at Resolver.resolveFull (/usr/local/lib/nodemodules/callin.io/nodemodules/.pnpm/@callin.io+vm2@3.9.25/nodemodules/@callin.io/vm2/lib/resolver.js:126:9)",
" at Resolver.resolve (/usr/local/lib/node
modules/callin.io/nodemodules/.pnpm/@callin.io+vm2@3.9.25/nodemodules/@callin.io/vm2/lib/resolver.js:121:15)",
" at resolve (/usr/local/lib/nodemodules/callin.io/nodemodules/.pnpm/@callin.io+vm2@3.9.25/nodemodules/@callin.io/vm2/lib/nodevm.js:317:21)",
" at VM2 Wrapper.apply (/usr/local/lib/node
modules/callin.io/nodemodules/.pnpm/@callin.io+vm2@3.9.25/nodemodules/@callin.io/vm2/lib/bridge.js:490:11)",
" at requireImpl (/usr/local/lib/nodemodules/callin.io/nodemodules/.pnpm/@callin.io+vm2@3.9.25/nodemodules/@callin.io/vm2/lib/setup-node-sandbox.js:90:19)",
" at require (/usr/local/lib/node
modules/callin.io/nodemodules/.pnpm/@callin.io+vm2@3.9.25/nodemodules/@callin.io/vm2/lib/setup-node-sandbox.js:171:10)",
" at /usr/local/lib/nodemodules/callin.io/nodemodules/.pnpm/callin.io-nodes-base@file+packages+nodes-base@aws-sdk+credential-providers@3.808.0asn1.js@51af219c3f47f2a1223ec4ccec249a974/nodemodules/callin.io-nodes-base/dist/nodes/Code:1:116",
" at /usr/local/lib/nodemodules/callin.io/nodemodules/.pnpm/callin.io-nodes-base@file+packages+nodes-base@aws-sdk+credential-providers@3.808.0asn1.js@51af219c3f47f2a1223ec4ccec249a974/nodemodules/callin.io-nodes-base/dist/nodes/Code:3:2",
" at VM2 Wrapper.apply (/usr/local/lib/nodemodules/callin.io/nodemodules/.pnpm/@callin.io+vm2@3.9.25/nodemodules/@callin.io/vm2/lib/bridge.js:490:11)",
" at NodeVM.run (/usr/local/lib/node
modules/callin.io/nodemodules/.pnpm/@callin.io+vm2@3.9.25/nodemodules/@callin.io/vm2/lib/nodevm.js:497:23)"
]
}
}

 
Posted : 28/07/2025 3:59 pm
jabbson
(@jabbson)
Posts: 40
Eminent Member
 

This might actually be the issue, depending on how you restarted the container. Containers are temporary components, and if you stop and restart your infrastructure, it generates a new one, which won't have the parser installed.

 
Posted : 28/07/2025 4:02 pm
Hellboy
(@hellboy)
Posts: 7
Active Member
Topic starter
 

I attempted to install the mailparser without restarting the container this time, but I'm still encountering the same error.

bash
/home/node # npm install -g mailparser

```
changed 27 packages in 1s

11 packages are looking for funding
run npm fund for details
```

json
{
"errorMessage": "Cannot find module ‘mailparser’ [line 1]",
"errorDescription": "VMError",
"errorDetails": {},
"n8nDetails": {
"nodeName": "Code1",
"nodeType": "n8n-nodes-base.code",
"nodeVersion": 2,
"n8nVersion": "1.103.2 (Self Hosted)",
"binaryDataMode": "default",
"stackTrace": [
"VMError: Cannot find module ‘mailparser’",
" at Resolver.resolveFull (/usr/local/lib/node_modules/callin.io/node_modules/.pnpm/@callin.io+vm2@3.9.25/node_modules/@callin.io/vm2/lib/resolver.js:126:9)",
" at Resolver.resolve (/usr/local/lib/node_modules/callin.io/node_modules/.pnpm/@callin.io+vm2@3.9.25/node_modules/@callin.io/vm2/lib/resolver.js:121:15)",
" at resolve (/usr/local/lib/node_modules/callin.io/node_modules/.pnpm/@callin.io+vm2@3.9.25/node_modules/@callin.io/vm2/lib/nodevm.js:317:21)",
" at VM2 Wrapper.apply (/usr/local/lib/node_modules/callin.io/node_modules/.pnpm/@callin.io+vm2@3.9.25/node_modules/@callin.io/vm2/lib/bridge.js:490:11)",
" at requireImpl (/usr/local/lib/node_modules/callin.io/node_modules/.pnpm/@callin.io+vm2@3.9.25/node_modules/@callin.io/vm2/lib/setup-node-sandbox.js:90:19)",
" at require (/usr/local/lib/node_modules/callin.io/node_modules/.pnpm/@callin.io+vm2@3.9.25/node_modules/@callin.io/vm2/lib/setup-node-sandbox.js:171:10)",
" at /usr/local/lib/node_modules/callin.io/node_modules/.pnpm/callin.io-nodes-base@file+packages+nodes-base_@aws-sdk+credential-providers@3.808.0_asn1.js@5_1af219c3f47f2a1223ec4ccec249a974/node_modules/callin.io-nodes-base/dist/nodes/Code:1:116",
" at /usr/local/lib/node_modules/callin.io/node_modules/.pnpm/callin.io-nodes-base@file+packages+nodes-base_@aws-sdk+credential-providers@3.808.0_asn1.js@5_1af219c3f47f2a1223ec4ccec249a974/node_modules/callin.io-nodes-base/dist/nodes/Code:3:2",
" at VM2 Wrapper.apply (/usr/local/lib/node_modules/callin.io/node_modules/.pnpm/@callin.io+vm2@3.9.25/node_modules/@callin.io/vm2/lib/bridge.js:490:11)",
" at NodeVM.run (/usr/local/lib/node_modules/callin.io/node_modules/.pnpm/@callin.io+vm2@3.9.25/node_modules/@callin.io/vm2/lib/nodevm.js:497:23)"
]
}
}

 
Posted : 28/07/2025 4:12 pm
nabossha
(@nabossha)
Posts: 4
New Member
 

Everything looks good from my end. Have you confirmed that mailparser has the necessary execution permissions?

On my instance, I've included the following in the Docker-ENV variables:


NODE_FUNCTION_ALLOW_EXTERNAL=mailparser

and


N8N_REINSTALL_MISSING_PACKAGES=true

This ensures the package is added when I update callin.io.

 
Posted : 28/07/2025 8:50 pm
Hellboy
(@hellboy)
Posts: 7
Active Member
Hellboy
(@hellboy)
Posts: 7
Active Member
Topic starter
 

Hi there!

Please review the complete workflow screenshots.

It appears the mailparser is functioning correctly; please check the third screenshot.

I utilized your code from a previous post to extract email headers, but I'm encountering an error.

Error details:

json
{
"errorMessage": "Input cannot be null or undefined. [line 9]",
"errorDescription": "TypeError",
"errorDetails": {},
"n8nDetails": {
"nodeName": "Code2",
"nodeType": "n8n-nodes-base.code",
"nodeVersion": 2,
"n8nVersion": "1.103.2 (Self Hosted)",
"binaryDataMode": "default",
"stackTrace": [
"TypeError: Input cannot be null or undefined.",
" at module.exports (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/mailparser@3.6.7/node_modules/mailparser/lib/simple-parser.js:7:15)",
" at ReadOnlyHandler.apply (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/@n8n+vm2@3.9.25/node_modules/@n8n/vm2/lib/bridge.js:490:11)",
" at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@aws-sdk+credential-providers@3.808.0_asn1.js@5_1af219c3f47f2a1223ec4ccec249a974/node_modules/n8n-nodes-base/dist/nodes/Code:9:9",
" at new Promise ()",
" at new localPromise (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/@n8n+vm2@3.9.25/node_modules/@n8n/vm2/lib/setup-sandbox.js:33:1)",
" at parseEmail (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@aws-sdk+credential-providers@3.808.0_asn1.js@5_1af219c3f47f2a1223ec4ccec249a974/node_modules/n8n-nodes-base/dist/nodes/Code:8:12)",
" at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@aws-sdk+credential-providers@3.808.0_asn1.js@5_1af219c3f47f2a1223ec4ccec249a974/node_modules/n8n-nodes-base/dist/nodes/Code:31:27",
" at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@aws-sdk+credential-providers@3.808.0_asn1.js@5_1af219c3f47f2a1223ec4ccec249a974/node_modules/n8n-nodes-base/dist/nodes/Code:45:2",
" at VM2 Wrapper.apply (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/@n8n+vm2@3.9.25/node_modules/@n8n/vm2/lib/bridge.js:490:11)",
" at NodeVM.run (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/@n8n+vm2@3.9.25/node_modules/@n8n/vm2/lib/nodevm.js:497:23)"
]
}
}

 
Posted : 28/07/2025 9:04 pm
jabbson
(@jabbson)
Posts: 40
Eminent Member
 

Could you share the code from the Code2 Code Node?

This issue might be occurring because you're reading the input as:

javascript
const emailContent = $input.first().json['data'];

However, I don't see a data property in the input; instead, I see emlText. Please verify this.

It seems that when you call SimpleParser on line 9, you're passing the output from the previous node. But when you extract that output, you're getting data instead of emlText. This results in the content being empty, which is why you're encountering the error Input cannot be null or undefined.

 
Posted : 29/07/2025 12:24 am
nabossha
(@nabossha)
Posts: 4
New Member
 

Here's my test workflow:

 
Posted : 29/07/2025 7:32 am
Hellboy
(@hellboy)
Posts: 7
Active Member
Topic starter
 

You are correct, I was calling incorrectly. I updated the code to use ‘data’ instead of ‘emlText’, and it worked fine.

 
Posted : 29/07/2025 8:28 pm
jabbson
(@jabbson)
Posts: 40
Eminent Member
 

Great! Thanks for confirming. If this assisted you in resolving your issue, please consider marking the answer as the solution. Thank you.

Best regards!

 
Posted : 29/07/2025 8:29 pm
Hellboy
(@hellboy)
Posts: 7
Active Member
Topic starter
 

Thanks for the support! I also tried your approach, and it worked well, even better than my own. I'll be implementing your method.

 
Posted : 29/07/2025 8:29 pm
Share: