Change email subject

Technical Support
  • I know that one can mess around with the email templates, but I see no way to change the subject of the email.
    Like:

    [sitename #topic_id] topic_name
    

    I need to include the topic id in the subject because I need to parse the subject ( postfix forward pointing to a Yii console controller, if you must know) - do I need to mess around in the source code?

    Edit:
    I am implementing reply by email, btw.
    And since I am a PHP developer, I am using the api and dirty tricks πŸ˜‰

  • I also do know that I can grab the topic id from the URL - that thought came to me just now πŸ˜› - but it is easier to just regex the subject.

  • Emailer fires:

    Plugins.fireHook('filter:email.modify', data, next);

    Listen to that hook, modify subject in data, voila.

  • /* puts nodejs on list of stuff to learn .. */

    Ok, I will perhaps try and look into that πŸ˜‰

  • I just did a stupidly simple (stupid?) plugin but it does not seem to do much πŸ™‚

    (function(module) {
        "use strict";
    
        var autoreplyit = {};
    
        autoreplyit.filter = function(data) {
            data.subject = data.subject + ' #' + data.pid;
        };
    
        module.exports = autoreplyit;
    }(module));
    
    {
        "id": "nodebb-plugin-autoreplyit",
        "name": "NodeBB Autoreply email subject changer",
        "description": "NodeBB Plugin that changes the email subject field to include the topic id.",
        "url": "https://github.com/jacmoe/nodebb-plugin-autoreplyit",
        "library": "./library.js",
        "hooks": [
            { "hook": "filter:email.modify", "method": "filter" }
        ]
    }
    
  • Check to see that autoreplyit.filter is executed (maybe a console.log?)

    Your filter will need a callback:

    autoreplyit.filter = function(data, callback) {
      data.subject = data.subject + ' #' + data.pid;
      callback(null, data);
    };
    
    
  • It works πŸ™‚
    0_1450084954543_nodebb5.jpg

    (function(module) {
        "use strict";
    
        var autoreplyit = {};
    
        autoreplyit.filter = function(data, callback) {
            var re = /http:\/\/nodebbjacmoe-jacmoe\.rhcloud\.com\/topic\/(\d+)/;
            var str = data.plaintext;
            var found = str.match(re);
            data.subject = data.subject + ' #' + found[1];
            callback(null, data);
        };
    
        module.exports = autoreplyit;
    }(module));
    

    Totally hard-coded, of course πŸ˜›

    Edit:
    I am fully aware that it is only a matter of time before a kind soul points out to me that I can easily get the site url from a dark corner of the API - but, hey: it works.
    Now the receiving PHP script can grab the topic id and make sure that it is sent to the right place.

  • Thanks a lot @julian πŸ™‚

  • @Jacob-Moen Hey, if it works, it works!

    Now you've written a NodeBB plugin πŸ˜„

  • I threw in an if(found) just in case - but I am always amazed by how little code is required.
    That seem to happen a lot with Node.js and a well written software entitled NodeBB πŸ‘


Suggested Topics


  • 0 Votes
    18 Posts
    341 Views

    @phenomlab said in How to change Font type? (serif vs. sans-serif):

    @crazycells they can only be used on websites if they are installed and included in the site you are viewing. This basically means that unless the font is available on he remote server, it won't display to other users if they do not have it installed (but would for you if you have it installed)

    This is why CSS on most websites will use system as a fallback so that the text is rendered even if the font cannot be found rather than the default of Times New Roman being displayed. System essentially uses whatever font is the default on the system viewing the website. In essence, under Windows, this would be SegoeUI. Under a Mac, it's of course different.

    Importing a font into your website isn't a difficult task. It's explained very well here

    How to import Google Web Font in CSS file?

    I'm working with a CMS which I only have access to the CSS file. So, I can't include anything in the <head> of the document. I was wondering if there was a way to import the web font from wit...

    favicon

    Stack Overflow (stackoverflow.com)

    However, if you'd like to include a font that isn't from Google this is still possible, but the process differs slightly - and the caveat here is that not all fonts are created equal. Some do not lend themselves very well to rendering within web pages, and so it's always best to go for "web safe" versions. For example, just try "master of puppets" (yes, Metallica) and see what happens !

    In an seriousness, if you need help with fonts etc, happy to help.

    thank you very much, this was helpful! I will let you know about the progress πŸ‘

  • 0 Votes
    2 Posts
    235 Views

    @the-cat-gaming-099 I don't believe this is possible because of how NodeBB is written. You need email to reset password, receive notifs, and for the database and core to see the users.
    I suppose it could be possible, but you'd have to modify core yourself and it'd be pretty complicated and to be honest, not worth it.

  • 0 Votes
    7 Posts
    936 Views

    I dont see a way to disable login under Settings -> User, using NodeBB version 1.12.2

  • 0 Votes
    2 Posts
    929 Views

    Using an emailer plugin is the suggested way of solving this https://github.com/julianlam/nodebb-plugin-emailer-sendgrid

  • send email error 404

    Unsolved Technical Support
    1
    0 Votes
    1 Posts
    730 Views

    can't send email error in log appear
    0_1476424059317_upload-ad740a92-55a2-4d83-8e5e-1875658e3961