email modification hook
-
I'm currently using
{ "hook": "action:email.send", "method": "email", "priority": 5 }
within the emoji-extended plugin.json, it resolves to this function:
function(data){ return data.html+="\n<style type='text/css'>"+EMAIL_STYLE+"</style>" }
(compiled coffeescript,
EMAIL_STYLE
is a defined variable)I'm sure this has been working some time ago in local tests for appending those styles to any emails.
It's not working anymore as it seems. I cannot find the appended styles anywhere within emails I receive.I can't figure out why it's not working anymore. It's all synchronous, so the change within the data should trigger before the call of the mailers (with default priority, 10) action-hook. And even so it's an
action
hook thepriority
matters according to my reverse-engineering...I'd love to see this hook being replaced with a
filter
since such use is dirty and prevents asynchronous handling. Maybe this would also solve the problem...Tested with emails of this board...
-
They never did to my knowledge, the
return
is just coffeescript generated, isn't supposed to change anything.
Why it worked was because of the strict synchronous call order: thefireHook
->asyn.each
-> my hook-method doesn't have anything asynchronous inside (theasync.each
works synchronous ifnext
is called synchronously, I checked the source). So my change ofdata.html
should be before the emailers hook-method gets called in each case. And since it's a change within thedata
object that gets passed to the emailers hook-method later on the change should be working.We can possibly add a filter:email.send
Would be great In this case the question why it's not working anymore is just nice to know... If anybody has an idea...
-
Didn't thought of this yet o_O
But I assume if it's the mailserver it's more probable that it filters out everything that's not contained by thehtml
tag...
I assume I'll need some better string-manipulation then.Can I assume that any html-string for emails contains a
head
-tag?