Mail Plugin

Java class implementation:


Available since: v. 1.2.0.


Allows to send (and in future read) emails.


This plugin is configured as a Server handler. The plugin can be configured in easy way by changing parameters:

enabledtrue to turn on, false (default) is turned offbooleantrue1.2.0
profile.<name>.mail.smtp.hostThe SMTP host name or
profile.<name>.mail.smtp.portThe SMTP portnumber5871.2.0
profile.<name>.mail.smtp.authAuthenticate in SMTPbooleantrue1.2.0
profile.<name>.mail.smtp.starttls.enableEnable the starttlsbooleantrue1.2.0
profile.<name>.mail.smtp.userThe SMTP usernamestringyoda@starwars.com1.2.0
profile.<name>.mail.fromThe source's email addressstringyoda@starwars.com1.7
profile.<name>.mail.smtp.passwordThe SMTP passwordstringUseTh3F0rc31.2.0
profile.<name> date format to use, default is "yyyy-MM-dd HH:mm:ss"stringyyyy-MM-dd HH:mm:ss1.2.0

Default configuration in orientdb-server-config.xml. Example:

    <parameter name="enabled" value="true" />
    <!-- CREATE MULTIPLE PROFILES WITH profile.<name>... -->
    <parameter name="" value=""/>
    <parameter name="profile.default.mail.smtp.port" value="587" />
    <parameter name="profile.default.mail.smtp.auth" value="true" />
    <parameter name="profile.default.mail.smtp.starttls.enable" value="true" />
    <parameter name="profile.default.mail.from" value="" />
    <parameter name="profile.default.mail.smtp.user" value="" />
    <parameter name="profile.default.mail.smtp.password" value="mypassword" />
    <parameter name="" value="yyyy-MM-dd HH:mm:ss" />


The message is managed as a map of properties containing all the fields those are part of the message.

Supported message properties:

fromsource email addressNoto : "", ""1.7
todestination addresses separated by commasYesto : "", ""1.2.0
ccCarbon copy addresses separated by commasNocc: "", ""1.2.0
bccBlind Carbon Copy addresses separated by commasNobcc : "", ""1.2.0
subjectThe subject of the messageNosubject : "This Email plugin rocks!"1.2.0
messageThe message's contentYesmessage : "Hi, how are you mate?"1.2.0
dateThe subject of the message. Pass a java.util.Date object or a string formatted following the rules specified in "" configuration parameter or "yyyy-MM-dd HH:mm:ss" is takenNo, if not specified current date is assumeddate : "2012-09-25 13:20:00"1.2.0
attachmentsThe files to attachNo1.2.0

From Server-Side Functions

The Email plugin install a new variable in the server-side function's context: "mail". "profile" attribute is the profile name in configuration.

Example to send an email writing a function in JS:

      profile : "default",
      to: "",
      cc: "",
      bcc: "",
      subject: "The EMail plugin works",
      message : "Sending email from OrientDB Server is so powerful to build real web applications!"

On Nashorn (>= Java8) the mapping of JSON to Map is not implicit. Use this:

mail.send( new java.util.HashMap{
      profile : "default",
      to: "",
      cc: "",
      bcc: "",
      subject: "The EMail plugin works",
      message : "Sending email from OrientDB Server is so powerful to build real web applications!"

From Java

OMailPlugin plugin = OServerMain.server().getPlugin("mail");

Map<String, Object> message = new HashMap<String, Object>();
message.put("profile", "default");
message.put("to",      "");
message.put("cc",      ",");
message.put("bcc",     "");
message.put("subject", "The EMail plugin works");
message.put("message", "Sending email from OrientDB Server is so powerful to build real web applications!");


results matching ""

    No results matching ""