Mail Plugin - aemadrid/orientdb GitHub Wiki

E-Mail plugin

Java class implementation:

    com.orientechnologies.orient.server.plugin.mail.OMailPlugin

Available since: v. 1.2.0.

Introduction

Allows to send (and in future read) emails.

Configuration

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

Name Description Type Example Since
enabled true to turn on, false (default) is turned off boolean true 1.2.0
profile.<name>.mail.smtp.host The SMTP host name or ip-address string smtp.gmail.com 1.2.0
profile.<name>.mail.smtp.port The SMTP port number 587 1.2.0
profile.<name>.mail.smtp.auth Authenticate in SMTP boolean true 1.2.0
profile.<name>.mail.smtp.starttls.enable Enable the starttls boolean true 1.2.0
profile.<name>.mail.smtp.user The SMTP username string [email protected] 1.2.0
profile.<name>.mail.smtp.password The SMTP password string UseTh3F0rc3 1.2.0
profile.<name>.mail.date.format The date format to use, default is "yyyy-MM-dd HH:mm:ss" string yyyy-MM-dd HH:mm:ss 1.2.0

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

    <!-- MAIL, TO TURN ON SET THE 'ENABLED' PARAMETER TO 'true' -->
    <handler 
    class="com.orientechnologies.orient.server.plugin.mail.OMailPlugin">
      <parameters>
        <parameter name="enabled" value="true" />
        <!-- CREATE MULTIPLE PROFILES WITH profile.<name>... -->
        <parameter name="profile.default.mail.smtp.host" value="smtp.gmail.com"/>
        <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.smtp.user" value="[email protected]" />
        <parameter name="profile.default.mail.smtp.password" value="mypassword" />
        <parameter name="profile.default.mail.date.format" value="yyyy-MM-dd HH:mm:ss" />
      </parameters>
    </handler>

Usage =

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

Supported message's properties:

Name Description Mandatory Example Since
to destination addresses separated by commas Yes to : "[email protected]", "[email protected]" 1.2.0
cc Carbon copy addresses separated by commas No cc: "[email protected]", "[email protected]" 1.2.0
bcc Blind Carbon Copy addresses separated by commas No bcc : "[email protected]", "[email protected]" 1.2.0
subject The subject of the message No subject : "This Email plugin rocks!" 1.2.0
message The message's content Yes message : "Hi, how are you mate?" 1.2.0
date The subject of the message. Pass a java.util.Date object or a string formatted following the rules specified in "mail.date.format" configuration parameter or "yyyy-MM-dd HH:mm:ss" is taken No, if not specified current date is assumed date : "2012-09-25 13:20:00" 1.2.0
attachments The files to attach No attachments : ["tmp/2.eml"]("tmp/1.pdf",) 1.2.0

= From Server-Side Functions

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

Example to send an email writing a function in JS:

    mail.send({
      to: "[email protected]",
      cc: "[email protected]",
      bcc: "[email protected]",
      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("to",      "[email protected]");
    message.put("cc",      "[email protected]");
    message.put("bcc",     "[email protected]");
    message.put("subject", "The EMail plugin works");
    message.put("message", "Sending email from OrientDB Server is so powerful to build real web applications!");
    
    plugin.send(message);
⚠️ **GitHub.com Fallback** ⚠️