Skip to content

class net.SMTPConnection

Ayhan Rashidov edited this page Sep 5, 2022 · 2 revisions

$.net.SMTPConnection Class

Class for sending $.net.Mail objects via SMTP connection.

Reference

SAP Help

https://help.sap.com/doc/3de842783af24336b6305a3c0223a369/2.0.03/en-US/$.net.SMTPConnection.html

Module

https://github.com/codbex/codbex-kronos/tree/main/modules/api/api-xsjs/src/main/resources/META-INF/dirigible/kronos/net

Sample Usage

var net = $.net

// Create email from JS Object.
var mail = new net.Mail({
   sender: {address: "sender@sap.com"},
   to: [{ name: "John Doe", address: "john.doe@sap.com"}, {name: "Jane Doe", address: "jane.doe@sap.com"}],
   cc: [{address: "cc1@sap.com"}, {address: "cc2@sap.com"}],
   bcc: [{ name: "Jonnie Doe", address: "jonnie.doe@sap.com"}],
   subject: "subject",
   subjectEncoding: "UTF-8",
   parts: [ new net.Mail.Part({
       type: net.Mail.Part.TYPE_TEXT,
       text: "The body of the mail.",
       contentType: "text/plain",
       encoding: "UTF-8",
   })]
});

// Set mail server configurations.
let mailConfig = {
    "mail.user": "<your-user>",
    "mail.password": "<your-password>",
    "mail.transport.protocol": "smtps",
    "mail.smtps.host": "<your-mail-provider-host>",
    "mail.smtps.port": "465",
    "mail.smtps.auth": "true"
};

var smtp = new net.SMTPConnection(mailConfig);
let returnValue = smtp.send(mail);

$.response.setBody(JSON.stringify(returnValue));

Coverage

Methods Return Type Description Status
close() void Mocked. The SMTP Connection is now automatically closed after calling the send method.
isClosed() boolean Mocked. The SMTP Connection is always closed.
send(Mail) void Accepts and sends the net.Mail class.

Unit Tests ⚠️

https://github.com/codbex/codbex-kronos/tree/main/modules/engines/engine-xsjs/src/test/resources/META-INF/dirigible/test/kronos/net

Integration Tests ❌

Wiki icons legend

✅ - Feature implemented and working as supposed.
⚠️ - Feature partially implemented and needs to be finished.
❌ - Feature not implemented yet.

Clone this wiki locally