email modification hook


  • Plugin & Theme Dev

    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 the priority 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...



  • Yeah actions don't have any return values, maybe they did long ago, but that is not the case anymore. We can possibly add a filter:email.send


  • Plugin & Theme Dev

    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: the fireHook -> asyn.each -> my hook-method doesn't have anything asynchronous inside (the async.each works synchronous if next is called synchronously, I checked the source). So my change of data.html should be before the emailers hook-method gets called in each case. And since it's a change within the data 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...


  • GNU/Linux Admin

    Possibly the mail server strips out style tags? 😄


  • Plugin & Theme Dev

    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 the html tag...
    I assume I'll need some better string-manipulation then.

    Can I assume that any html-string for emails contains a head-tag?


  • GNU/Linux Admin

    Actually, I don't think we use those tags at all. We just send html without the appropriate wrappings (<html>, <head>, etc), assuming that the mail server will do it for us.


Log in to reply
 

Suggested Topics

| |