Join GitHub today
Allow hashes to be submitted as headers #185
Thanks for this awesome gem! I am finding it super useful. :-) I am pretty new to this whole thing, so please let me know if I have missed something or there is a much better way of doing this.
Allow hashes to be sent as headers from the adapter gems.
I looked at the Mandrill, Sendgrid, PostMark gems and as far as I can see none of them submit header params.
If a hash is submitted when it is processed by the Mail::Header class it will throw an exception. My logic is that if the headers are already formatted hashes, then they do not need to be processed by Mail::Header.
I have added a test to confirm that hashes are dealt with correctly.
I look forward to your feedback.
In the case of the Mandrill adapter (the one I am working with), I need to be able to access the headers, so I added the ability to send headers to the mandrill adapter in the same way as all the other params are sent. Which is extracting a hash from the JSON provided by Mandrill.
Once I added sending headers to there adapter, there was always an exception thrown by this gem and this is caused by the string processing of Mail::Header.
Once this is merged (if it is) I will get headers added to the Mandrill adapter (at least).
You can see how I have added headers into the Mandrill Adapter here - https://github.com/matthewbarram/griddler-mandrill/blob/master/lib/griddler/mandrill/adapter.rb#L21 and this implementation will only work with this change.
Converting the headers hash into a string and then converting it back doesn't make much sense to me. Especially since Mandrill (maybe the others) already formats the headers in a well formatted hash.
The concept is sound, but I still worry a bit that we're just passing along whatever "headers" are provided to us. Passing through
That said, it's been requested often.
An interesting scenario (that I just encountered): header keys are intended to be case-insensitive, so, e.g., both
A safer fix might be for griddler to handle either String or Hash inputs, but force them both through the
We are using the CloudMailin adapter, with CloudMailin's JSON format. This sends us a
For the same reasons as other contributors to this thread, I'd like Griddler to allow a