I have successfully setup the postmark API in my rails dev environment and am trying to embed metadata containing record ID so I can process the record in my webhook. I receive a response from postmark into my webhook URL upon email delivery, but the application log shows the metadata blank. I have tried entering the metadata in hash notation as well but to no avail:
Processing by WebhooksController#create as HTML
Parameters: {"MessageID"=>"b0c2673e-9628-4725-b9bb-xxxxxxxxxxxx", "Recipient"=>"nnnn@eee.ddd", "DeliveredAt"=>"2022-02-13T08:46:30Z",
"Details"=>"smtp;250 OK id=1nJAWV-001Lmg-Eu", "Tag"=>"", "ServerID"=>nnnnnnnnnn, "Metadata"=>{}, "RecordType"=>"Delivery",
"MessageStream"=>"outbound", "token"=>"xxxxxxxxxxxxx", "webhook"=>{"MessageID"=>"b0c2673e-9628-4725-b9bb-xxxxxxxxxxxx",
"Recipient"=>"nnnn@eee.ddd", "DeliveredAt"=>"2022-02-13T08:46:30Z", "Details"=>"smtp;250 OK id=1nJAWV-001Lmg-Eu", "Tag"=>"",
"ServerID"=>nnnnnnnnnn, "Metadata"=>{}, "RecordType"=>"Delivery", "MessageStream"=>"outbound"}}
My mail block is as follows:
mail(
from: @invoice.account.company_email,
to: @invoice.email,
cc: @invoice.also_email,
subject: "Invoice %s has been generated." % [@invoice.to_s],
metadata: { "invoice_id": "bd2533a8-c00b-4830-97dc-xxxxxxxxxx" },
message_stream: 'outbound',
body: email_body
) do |format|
format.html {email_body}
end
As can be seen, I'm presently hard coding the id into the metadata while I try to solve this issue.
Interestingly, when I use the Postmark test stream, and view the raw data of the email, the metadata is showing (excerpt only):
metadata: {:invoice_id=>"bd2533a8-c00b-4830-97dc-xxxxxxxxxx"}
Feedback-ID: snnnnnn-_:snnnnnn:a22nnnn:postmark
X-Complaints-To: abuse@postmarkapp.com
X-Job: 227735_860nnnn
In addition to the metadata issue, I am receiving only delivery responses. I have open tracking enabled at the server level but aren't receiving any.
Any help would be greatly appreciated and thanks in advance. Oh, and I'm using the postmark-rails gem in rails in conjunction with actionmailer.