Mail

Mail object is used to send e-mails through the mail service.

Version 4.x

Basic Usage

1
2
3
4
5
6
7
8
9
10
11
12
var response = require("http/v4/response");
var mail = require("mail/v4/client");

var from = "dirigible@eclipse.org";
var to = "example@gmail.com";
var subject = "Subject";
var content = "<h1>Content<h1>";
var subType = "html";

mail.send(from, to, subject, content, subType);

response.println("Mail sent");

Advance Usage

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var response = require("http/v4/response");
var mail = require("mail/v4/client");

var mailConfig = {
	"mail.user": "<your-user>",
	"mail.password": "<your-password>",
	"mail.transport.protocol": "smtps",
	"mail.smtps.host": "smtp.gmail.com",
	"mail.smtps.port": "465",
	"mail.smtps.auth": "true"
};

var mailClient = mail.getClient(mailConfig);

var from = "dirigible@gmail.com";
var recipients = {
	to: "example@gmail.com",
	cc: ["example1@gmail.com", "example2@sap.com"],
	bcc: "example3@sap.com"
};
var subject = "Subject";
var content = "<h1>Content</h1>";
var subType = "html";

mailClient.send(from, recipients, subject, content, subType);

response.println("Mail sent");

Definition

Functions


Function Description Returns
getClient(options) Get mail client with the provided MailClientOptions, if no options are provided, the default mail client configuration will be used MailClient
send(from, recipients, subject, text, subType) Send mail using the default mail client configuration to MailRecipients -

Objects


MailClient

Property Description Type
send(from, recipients, subject, text, subType) Send mail to MailRecipients MailClient function

MailClientOptions

Property Description Type
mail.user The mailbox user string
mail.password The mailbox password string
mail.transport.protocol (optional) The mail transport protocol, default is smtps string
mail.smtps.host The mail SMPTPS host string
mail.smtps.port The mail SMPTPS port number as string
mail.smtps.auth Enable/Disable mail SMPTPS authentication boolean as string
mail.smtp.host The mail SMPTP host string
mail.smtp.port The mail SMPTP port number as string
mail.smtp.auth Enable/Disable mail SMPTP authentication boolean as string

Addition mail client options can be found here:

MailRecipients

Property Description Type
to The to recipient(s) string or Array of strings
cc The cc recipient(s) string or Array of strings
bcc The bcc recipient(s) string or Array of strings

Compatibility

Rhino Nashorn V8
Edit