class net.SMTPConnection - SAP-archive/xsk GitHub Wiki

$.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/SAP/xsk/tree/main/modules/api/api-xsjs/src/main/resources/xsk/net

  • Sample usage:
var net = $.net

// Create email from JS Object.
var mail = new net.Mail({
   sender: {address: "[email protected]"},
   to: [{ name: "John Doe", address: "[email protected]"}, {name: "Jane Doe", address: "[email protected]"}],
   cc: [{address: "[email protected]"}, {address: "[email protected]"}],
   bcc: [{ name: "Jonnie Doe", address: "[email protected]"}],
   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.
  • Issues

https://github.com/SAP/xsk/issues/19

  • Unit Tests

https://github.com/SAP/xsk/tree/main/modules/engines/engine-xsjs/src/test/resources/test/xsk/net/net.xsjs

  • Integration Tests ❌

Wiki icons legend

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

⚠️ **GitHub.com Fallback** ⚠️