HTTP API error

Hello Kumomta team, can you pls help me. I’m trying to send email via http API:

curl -H 'Content-Type: application/json' 'https://api.sendrapp.org/api/inject/v1' -d '{
  "envelope_sender": "test@erlangjobs.com",
  "content": "Subject: hello",
  "recipients": [
      {
          "email": "kazanlug@gmail.com"
      }
  ]
}'

Getting this error:

{"success_count":0,"fail_count":1,"failed_recipients":["kazanlug@gmail.com"],"errors":["kazanlug@gmail.com: runtime error: /opt/kumomta/share/policy-extras/dkim_sign.lua:182: attempt to index a nil value\nstack traceback:\n\t/opt/kumomta/share/policy-extras/dkim_sign.lua:182: in upvalue 'do_dkim_sign'\n\t/opt/kumomta/share/policy-extras/dkim_sign.lua:323: in upvalue 'dkim_signer'\n\t[string \"/opt/kumomta/etc/policy/init.lua\"]:91: in function <[string \"/opt/kumomta/etc/policy/init.lua\"]:90>"]}[

This is the line with error:

local sender_domain = msg:from_header().domain

While debugging I found that msg:from_header() is nil.
Same method I’m using for SMTP dkim sign and it works.
Thank you.

Hey there @dapper-yeti, thanks for posting. Please read the “Troubleshooting” and “How to Ask for Help” buttons below. If you would like a 1:1 support session from the KumoMTA team, details are at the “Book a Support Session” button below.

Yeah. In your injection, you have an envelope sender, but no header FROM. DKIM is signed on header FROM.

Take a look at the SECOND example on this page:

https://docs.kumomta.com/reference/http/api_inject_v1/

If you update to kumomta-dev builds you get a much clearer error message about this

Awesome thank you!!

We can close this, thanks again for the help!

Thank you for using KumoMTA :slightly_smiling_face: