TomB_Trisco
TomB_Trisco

Reputation: 21

WSO2 api manager jaggery extensions

In wso2 api manager we extended the store a bit with custom jaggery code. Now we would like to send an email from within the jaggery code. According to the jaggeryjs documentation this should be possible with the "new email.Sender" function. However, when using require("email") jaggery complains that that module could not be found.

I looked for it and assume it is in the jaggery extensions repo, which I downloaded and build with maven. However, now I'm at a loss what to do next and how to install those features maven built into wso2 am. There doesn't seem to be any documentation on this. Can anybody guide me?

The code I use (from:http://jaggeryjs.org/documentation.jag?api=sender)

if (result) {
    try
    {
        var content = question;
        var to = ".....";
        var subject = "Question from opendata faq page";

        var email = require('email');
        var smtpSettings = jagg.module("stib").getSmtpSettings();

        log.info(smtpSettings);

        var sender = new email.Sender(smtpSettings.host, smtpSettings.port, smtpSettings.user, smtpSettings.password);

        sender.from = "....";
        sender.to = to;
        sender.cc = email;
        sender.bcc = "";
        sender.subject = subject;
        sender.text = content;
        sender.send();

        return true;
    }
    catch(error) {
        log.error(error);
    }
}

Upvotes: 0

Views: 359

Answers (1)

Jenananthan
Jenananthan

Reputation: 1401

you can install the jaggery extension as features[1]. e.g for am 2.0.0 you can use the wilkes[1] repo and install the email module feature , this will install the jaggery extenstion

[1]https://docs.wso2.com/display/Carbon440/Installing+Features+via+the+UI

[2]http://product-dist.wso2.com/p2/carbon/releases/wilkes/

Upvotes: 0

Related Questions