Compare commits

..

14 Commits

Author SHA1 Message Date
Julien Fontanet
9b3668423e 0.2.0 2016-11-10 10:47:43 +01:00
badrAZ
3c11f0acda feat(test): this plugin is now testable (#9)
See vatesfr/xo-web#1749
2016-11-09 14:55:08 +01:00
Julien Fontanet
588c369615 fix(package): fix URLs 2016-11-02 11:45:31 +01:00
Julien Fontanet
14156b0911 chore(package): update all dependencies 2016-10-28 11:54:51 +02:00
Greenkeeper
1fd91de50d chore(package): update promise-toolbox to version 0.7.0 (#8)
https://greenkeeper.io/
2016-10-24 15:03:35 +02:00
Greenkeeper
7587458f99 Update promise-toolbox to version 0.6.0 🚀 (#7)
https://greenkeeper.io/
2016-10-12 09:12:14 +02:00
Greenkeeper
6980e2b959 chore(package): update babel-eslint to version 7.0.0 (#4)
https://greenkeeper.io/
2016-09-27 23:37:03 +02:00
Greenkeeper
f49f3fb2a6 Update all dependencies 🌴 (#3)
https://greenkeeper.io/
2016-09-25 16:20:17 +02:00
Olivier Lambert
6b82cc7510 fix(readme): typo 2016-08-12 17:22:28 +02:00
Julien Fontanet
592adcf42e 0.1.0 2016-06-29 10:40:03 +02:00
Julien Fontanet
978c881ab7 chore(package): update all dependencies 2016-06-29 10:39:05 +02:00
Julien Fontanet
d23df2ab15 0.0.6 2016-03-16 14:04:14 +01:00
Julien Fontanet
dbe828097c Do not set credentials if they are undefined. 2016-03-16 14:03:28 +01:00
Julien Fontanet
48a0623ded Fix handling of ignoreUnauthorized option. 2016-03-16 14:03:01 +01:00
9 changed files with 96 additions and 80 deletions

View File

@@ -1,11 +0,0 @@
{
"comments": false,
"compact": true,
"optional": [
"es7.asyncFunctions",
"es7.decorators",
"es7.exportExtensions",
"es7.functionBind",
"runtime"
]
}

View File

@@ -1,9 +1,7 @@
/.nyc_output/
/bower_components/
/dist/
/node_modules/
npm-debug.log
npm-debug.log.*
!node_modules/*
node_modules/*/
pnpm-debug.log
pnpm-debug.log.*

View File

@@ -1,5 +0,0 @@
Error.stackTraceLimit = 100
try { require('trace') } catch (_) {}
try { require('clarify') } catch (_) {}
try { require('source-map-support/register') } catch (_) {}

View File

@@ -1 +0,0 @@
--require ./.mocha.js

View File

@@ -1,9 +1,8 @@
language: node_js
node_js:
- 'stable'
- '6'
- '4'
- '0.12'
- '0.10'
# Use containers.
# http://docs.travis-ci.com/user/workers/container-based-infrastructure/

View File

@@ -4,42 +4,34 @@
## Install
Go inside your `xo-server` folder and install it:
Installation of the [npm package](https://npmjs.org/package/xo-server-transport-email):
```
> npm install xo-server-transport-email
> npm install --global xo-server-transport-email
```
## Usage
Edit your `xo-server` configuration and add the plugin name in the `plugins` section.
```yaml
plugins:
xo-server-transport-email:
```
Like all other xo-server plugins, it can be configured directly via
the web iterface, see [the plugin documentation](https://xen-orchestra.com/docs/plugins.html).
## Development
### Installing dependencies
```
# Install dependencies
> npm install
```
### Compilation
# Run the tests
> npm test
The sources files are watched and automatically recompiled on changes.
```
# Continuously compile
> npm run dev
```
### Tests
# Continuously run the tests
> npm run dev-test
```
> npm run test-dev
# Build for production (automatically called by npm install)
> npm run build
```
## Contributions
@@ -49,7 +41,7 @@ the code.
You may:
- report any [issue](https://google.com/vatesfr/xo-server-transport-email/issues)
- report any [issue](https://github.com/vatesfr/xo-server-transport-email/issues)
you've encountered;
- fork and create a pull request.

View File

@@ -1,18 +1,21 @@
{
"name": "xo-server-transport-email",
"version": "0.0.5",
"version": "0.2.0",
"license": "AGPL-3.0",
"description": "",
"keywords": [
"xo-server",
"email",
"mail"
"mail",
"orchestra",
"xen",
"xen-orchestra",
"xo-server"
],
"homepage": "https://google.com/vatesfr/xo-server-transport-email",
"bugs": "https://google.com/vatesfr/xo-server-transport-email/issues",
"homepage": "https://github.com/vatesfr/xo-server-transport-email",
"bugs": "https://github.com/vatesfr/xo-server-transport-email/issues",
"repository": {
"type": "git",
"url": "https://google.com/vatesfr/xo-server-transport-email"
"url": "https://github.com/vatesfr/xo-server-transport-email"
},
"author": {
"name": "Julien Fontanet",
@@ -24,38 +27,51 @@
"files": [
"dist/"
],
"engines": {
"node": ">=4"
},
"dependencies": {
"babel-runtime": "^5.8.34",
"nodemailer": "^1.10.0",
"nodemailer": "^2.4.2",
"nodemailer-markdown": "^1.0.0",
"pify": "^2.3.0"
"promise-toolbox": "^0.7.0"
},
"devDependencies": {
"babel": "^5.8.34",
"babel-eslint": "^4.1.5",
"clarify": "^1.0.5",
"babel-cli": "^6.10.1",
"babel-eslint": "^7.0.0",
"babel-preset-latest": "^6.16.0",
"babel-preset-stage-0": "^6.5.0",
"cross-env": "^3.1.3",
"dependency-check": "^2.5.1",
"mocha": "^2.3.4",
"must": "^0.13.1",
"nyc": "^3.2.2",
"source-map-support": "^0.3.3",
"standard": "^5.4.1",
"trace": "^2.0.1"
"ghooks": "^1.2.4",
"rimraf": "^2.5.4",
"standard": "^8.1.0"
},
"scripts": {
"build": "babel --source-maps --out-dir=dist/ src/",
"dev": "babel --watch --source-maps --out-dir=dist/ src/",
"dev-test": "mocha --opts .mocha.opts --watch --reporter=min \"dist/**/*.spec.js\"",
"lint": "standard",
"build": "cross-env NODE_ENV=production babel --source-maps --out-dir=dist/ src/",
"clean": "rimraf dist/",
"depcheck": "dependency-check ./package.json",
"dev": "cross-env NODE_ENV=development babel --watch --source-maps --out-dir=dist/ src/",
"lint": "standard",
"posttest": "npm run lint && npm run depcheck",
"prepublish": "npm run build",
"test": "nyc mocha --opts .mocha.opts \"dist/**/*.spec.js\""
"prebuild": "npm run clean",
"predev": "npm run clean",
"prepublish": "npm run build"
},
"babel": {
"presets": [
"latest",
"stage-0"
]
},
"standard": {
"ignore": [
"dist/**"
"dist"
],
"parser": "babel-eslint"
},
"config": {
"ghooks": {
"commit-msg": "npm test"
}
}
}

View File

@@ -1,6 +1,6 @@
import pify from 'pify'
import { createTransport } from 'nodemailer'
import { markdown as nodemailerMarkdown } from 'nodemailer-markdown'
import { promisify } from 'promise-toolbox'
// ===================================================================
@@ -93,6 +93,20 @@ export const configurationSchema = {
required: ['from', 'transport']
}
export const testSchema = {
type: 'object',
properties: {
to: {
type: 'string',
description: 'recipient of the test mail'
}
},
additionalProperties: false,
required: ['to']
}
// ===================================================================
class TransportEmailPlugin {
@@ -107,10 +121,10 @@ class TransportEmailPlugin {
}
configure ({
ignoreUnauthorized,
transport: {
user,
ignoreUnauthorized,
password,
user,
...transportConf
},
...conf
@@ -122,13 +136,15 @@ class TransportEmailPlugin {
).rejectUnauthorized = !ignoreUnauthorized
}
transportConf.auth = { user, pass: password }
if (user != null && password != null) {
transportConf.auth = { user, pass: password }
}
const transport = createTransport(transportConf)
transport.use('compile', markdownCompiler)
this._conf = conf
this._send = pify(::transport.sendMail, Promise)
this._send = promisify(transport.sendMail, transport)
}
load () {
@@ -139,16 +155,28 @@ class TransportEmailPlugin {
this._unset()
}
async _sendEmail ({
from,
test ({to}) {
return this._sendEmail({
to,
subject: '[Xen Orchestra] Test of transport-email plugin',
markdown: `Hi there,
The transport-email plugin for Xen Orchestra server seems to be working fine, nicely done :)`
})
}
_sendEmail ({
from = this._conf.from,
to, cc, bcc,
subject,
markdown
}) {
// TODO: handle errors
await this._send({
from: from || this._conf.from,
to, cc, bcc,
return this._send({
from,
to,
cc,
bcc,
subject,
markdown
}).catch(logAndRethrow)