Open benstaf opened 3 months ago
We actually implemented this feature experimentally in 2016 but removed it in 2019 due to the following three reasons: https://github.com/sisimai/rb-sisimai/tree/v4.25.0/lib/sisimai/bite/json
If you want to convert the JSON returned from SendGrid to a format compatible with Sisimai, the following code might be helpful. https://github.com/sisimai/rb-sisimai/blob/v4.25.0/lib/sisimai/bite/json/sendgrid.rb
I plan to do the opposite: convert the JSON returned by Sisimai into a SendGrid JSON, because SendGrid format is already supported by most mailing apps
This option would facilitate adoption of Sisimai
I understand what you're trying to achieve. If you're aiming to convert the data structure outputted by Sisimai into a format compatible with SendGrid, I believe that writing a script like the following would be the most concise, logical, and efficient approach.
#! /usr/bin/env ruby
require 'sisimai'
require 'oj'
v = Sisimai.rise('/path/to/mbox')
s = [] # SendGrid compatible format
if v.is_a? Array
v.each do |e|
r = {
'email' => e.recipient.address,
'event' => 'bounce',
... other fields
}
s << r
end
end
j = Oj.dump(s) if s.size > 0
Many apps are automatically compatible with SendGrid Webhook response format (it's the market leader):
https://www.twilio.com/docs/sendgrid/for-developers/tracking-events/event#example-webhook-response-5
On the other hand, making an app accept Sisimai webhook requires some customization:
https://libsisimai.org/en/start/
Is it possible to have a standardized SendGrid format output, so that it's automatically compatible with apps designed for SendGrid ?