This is a Personium's Engine extension for sending SMTP emails.
Please see Setup Engine Extensions.
- Clone this repository.
- Compile the source codes to
Ext_MailSender.jar
by maven commandmvn package -DskipTests=true
. - Edit property file to set the accessible SMTP server's host name and the port number.
- Set the jar module
Ext_MailSender.jar
and the property fileExt_MailSender.properties
into the Engine Extension directory in Personium application server. Default directory is/personium/personium-engine/extensions/
. - Restart tomcat process.
- Set an Engine Service which call this mail-sending function.
Sample script is below.
function(request) {
var mailObj = {
"to":[{"name":"John Doe","address":"john.doe@example.com"}],
"from": {
"address" : "admin@personium.io",
"name" : "Admin Office"
},
"reply-to": [{
"address" : "admin@personium.io",
"name" : "Admin Office"
}],
"envelope-from": "admin@personium.io",
"subject": "Greetings",
"text": "Hello\n Thank you!",
"charset": "UTF-8"
};
// in case of Japanese
// "charset": "ISO-2022-JP"
var sender = new _p.extension.MailSender();
// Call mail send method.
sender.send(mailObj);
return {
status : 200,
headers : {"Content-Type":"application/json"},
body : ['MailSender Complete!']
};
}
- Grant the
D:exec
privilege to using role and call Engine Execution API by the user who has this role.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.