• Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
v3.5.2 Latest
Buy Hosting

email modification hook

Scheduled Pinned Locked Moved NodeBB Plugins
pluginemailshook
6 Posts 3 Posters 2.8k Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • frissdiegurkeF Offline
    frissdiegurkeF Offline
    frissdiegurke Plugin & Theme Dev
    wrote on last edited by
    #1

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

    1 Reply Last reply
    0
  • barisB Offline
    barisB Offline
    <baris> NodeBB
    wrote on last edited by
    #2

    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

    1 Reply Last reply
    0
  • frissdiegurkeF Offline
    frissdiegurkeF Offline
    frissdiegurke Plugin & Theme Dev
    wrote on last edited by
    #3

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

    1 Reply Last reply
    0
  • julianJ Offline
    julianJ Offline
    julian GNU/Linux
    wrote on last edited by
    #4

    Possibly the mail server strips out style tags? 😄

    1 Reply Last reply
    0
  • frissdiegurkeF Offline
    frissdiegurkeF Offline
    frissdiegurke Plugin & Theme Dev
    wrote on last edited by
    #5

    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?

    1 Reply Last reply
    0
  • julianJ Offline
    julianJ Offline
    julian GNU/Linux
    wrote on last edited by
    #6

    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.

    1 Reply Last reply
    0

Copyright © 2023 NodeBB | Contributors
  • Login

  • Don't have an account? Register

  • Login or register to search.
Powered by NodeBB Contributors
  • First post
    Last post
0
  • Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development