-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
58 changed files
with
7,303 additions
and
2,808 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
SMTP_USERNAME= | ||
SMTP_PASSWORD= | ||
SMTP_HOST=smtp.mailtrap.io | ||
SMTP_PORT=25 | ||
SMTP_FROM_EMAIL= | ||
SMTP_TO_EMAIL= | ||
MAILTRAP_TOKEN= | ||
MAILTRAP_INBOX_ID= | ||
SPARKPOST_API_KEY= | ||
SPARKPOST_FROM_EMAIL= | ||
MAILGUN_API_KEY= | ||
MAILGUN_DOMAIN= | ||
SES_KEY= | ||
SES_SECRET= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,8 @@ coverage | |
node_modules | ||
.DS_Store | ||
npm-debug.log | ||
.idea | ||
out | ||
.nyc_output | ||
test/tmp | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,8 @@ test | |
.travis.yml | ||
.editorconfig | ||
benchmarks | ||
.idea | ||
bin | ||
out | ||
.nyc_output | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,10 @@ | ||
language: node_js | ||
env: | ||
- CXX=g++-4.8 | ||
addons: | ||
apt: | ||
sources: | ||
- ubuntu-toolchain-r-test | ||
packages: | ||
- g++-4.8 | ||
node_js: | ||
- node | ||
- 5.3.0 | ||
- 4.0.0 | ||
- 7.0.0 | ||
sudo: false | ||
install: | ||
- npm install --no-optional | ||
- npm install | ||
notifications: | ||
slack: | ||
secure: m91zkX2cLVDRDMBAUnR1d+hbZqtSHXLkuPencHadhJ3C3wm53Box8U25co/goAmjnW5HNJ1SMSIg+DojtgDhqTbReSh5gSbU0uU8YaF8smbvmUv3b2Q8PRCA7f6hQiea+a8+jAb7BOvwh66dV4Al/1DJ2b4tCjPuVuxQ96Wll7Pnj1S7yW/Hb8fQlr9wc+INXUZOe8erFin+508r5h1L4Xv0N5ZmNw+Gqvn2kPJD8f/YBPpx0AeZdDssTL0IOcol1+cDtDzMw5PAkGnqwamtxhnsw+i8OW4avFt1GrRNlz3eci5Cb3NQGjHxJf+JIALvBeSqkOEFJIFGqwAXMctJ9q8/7XyXk7jVFUg5+0Z74HIkBwdtLwi/BTyXMZAgsnDjndmR9HsuBP7OSTJF5/V7HCJZAaO9shEgS8DwR78owv9Fr5er5m9IMI+EgSH3qtb8iuuQaPtflbk+cPD3nmYbDqmPwkSCXcXRfq3IxdcV9hkiaAw52AIqqhnAXJWZfL6+Ct32i2mtSaov9FYtp/G0xb4tjrUAsDUd/AGmMJNEBVoHtP7mKjrVQ35cEtFwJr/8SmZxGvOaJXPaLs43dhXKa2tAGl11wF02d+Rz1HhbOoq9pJvJuqkLAVvRdBHUJrB4/hnTta5B0W5pe3mIgLw3AmOpk+s/H4hAP4Hp0gOWlPA= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,94 @@ | ||
# Adonis Mail | ||
# Adonis Mail 📩 | ||
|
||
[![Gitter](https://img.shields.io/badge/+%20GITTER-JOIN%20CHAT%20%E2%86%92-1DCE73.svg?style=flat-square)](https://gitter.im/adonisjs/adonis-framework) | ||
[![Trello](https://img.shields.io/badge/TRELLO-%E2%86%92-89609E.svg?style=flat-square)](https://trello.com/b/yzpqCgdl/adonis-for-humans) | ||
[![Version](https://img.shields.io/npm/v/adonis-mail-provider.svg?style=flat-square)](https://www.npmjs.com/package/adonis-mail-provider) | ||
[![Build Status](https://img.shields.io/travis/adonisjs/adonis-mail/master.svg?style=flat-square)](https://travis-ci.org/adonisjs/adonis-mail) | ||
[![Coverage Status](https://img.shields.io/coveralls/adonisjs/adonis-mail/master.svg?style=flat-square)](https://coveralls.io/github/adonisjs/adonis-mail?branch=master) | ||
[![Downloads](https://img.shields.io/npm/dt/adonis-mail-provider.svg?style=flat-square)](https://www.npmjs.com/package/adonis-mail-provider) | ||
[![License](https://img.shields.io/npm/l/adonis-mail-provider.svg?style=flat-square)](https://opensource.org/licenses/MIT) | ||
This repo is a AdonisJs provider to send emails using one of the available drivers, or by writing your own driver. | ||
|
||
> :pray: This repository contains email sending facilities for adonis framework. | ||
It uses [node mailer](https://nodemailer.com) internally to parse and send emails. | ||
|
||
Mail provider has support for several drivers to send email from your adonis app. | ||
[![NPM Version][npm-image]][npm-url] | ||
[![Build Status][travis-image]][travis-url] | ||
[![Appveyor][appveyor-image]][appveyor-url] | ||
[![Coveralls][coveralls-image]][coveralls-url] | ||
|
||
1. SMTP | ||
2. Amazon SES | ||
3. Mandrill | ||
4. Log ( for testing emails ) | ||
<img src="http://res.cloudinary.com/adonisjs/image/upload/q_100/v1497112678/adonis-purple_pzkmzt.svg" width="200px" align="right" hspace="30px" vspace="140px"> | ||
|
||
## Table of Contents | ||
## What's in the box? | ||
|
||
* [Team Members](#team-members) | ||
* [Getting Started](#getting-started) | ||
* [Contribution Guidelines](#contribution-guidelines) | ||
This repo contains following providers. | ||
|
||
## <a name="team-members"></a>Team Members | ||
1. Consistent API to send email | ||
2. Support for multiple drivers include **smtp**,**sparkmost**,**mailgun**,**amazon ses** etc. | ||
3. API to add your own drivers | ||
4. Write email content inside Edge templates. | ||
|
||
* Harminder Virk ([Caffiene Blogging](http://amanvirk.me/)) <virk.officials@gmail.com> | ||
## Node/OS Target | ||
|
||
## <a name="getting-started"></a>Getting Started | ||
This repo/branch is supposed to run fine on all major OS platforms and targets `Node.js >=7.0` | ||
|
||
## Development | ||
|
||
Great! If you are planning to contribute to the framework, make sure to adhere to following conventions, since a consistent code-base is always joy to work with. | ||
|
||
Run the following command to see list of available npm scripts. | ||
|
||
```bash | ||
$ npm i --save adonis-mail-provider | ||
``` | ||
npm run | ||
``` | ||
|
||
## Environment Variables | ||
|
||
There is a `.env.example` file in the project root, rename it as `.env` and add values for all services to run tests on your local. | ||
|
||
DO MAKE SURE TO NOT COMMIT THE `.env` FILE. | ||
|
||
### Tests & Linting | ||
|
||
1. Lint your code using standardJs. Run `npm run lint` command to check if there are any linting errors. | ||
2. Make sure you write tests for all the changes/bug fixes. | ||
3. Also you can write **regression tests**, which shows that something is failing but doesn't breaks the build. Which is actually a nice way to show that something fails. Regression tests are written using `test.failing()` method. | ||
4. Make sure all the tests are passing on `travis` and `appveyor`. | ||
|
||
### General Practices | ||
|
||
next register the provider in your `bootstrap/app.js` file. | ||
Since Es6 is in, you should strive to use latest features. For example: | ||
|
||
```bash | ||
const providers = [ | ||
'adonis-mail-provider/providers/MailProvider' | ||
] | ||
1. Use `Spread` over `arguments` keyword. | ||
2. Never use `bind` or `call`. After calling these methods, we cannot guarantee the scope of any methods and in AdonisJs codebase we do not override the methods scope. | ||
3. Make sure to write proper docblock. | ||
|
||
const aliases = { | ||
Mail: 'Adonis/Addons/Mail' | ||
} | ||
## Issues & PR | ||
|
||
It is always helpful if we try to follow certain practices when creating issues or PR's, since it will save everyone's time. | ||
|
||
1. Always try creating regression tests when you find a bug (if possible). | ||
2. Share some context on what you are trying to do, with enough code to reproduce the issue. | ||
3. For general questions, please create a forum thread. | ||
4. When creating a PR for a feature, make sure to create a parallel PR for docs too. | ||
|
||
|
||
## Regression Tests | ||
|
||
Regression tests are tests, which shows how a piece of code fails under certain circumstance, but the beauty is even after the failure, the test suite will never fail. Actually is a nice way to notify about bugs, but making sure everything is green. | ||
|
||
The regression tests are created using | ||
|
||
``` | ||
test.failing('2 + 2 is always 4, but add method returns 6', (assert) => { | ||
assert.true(add(2, 2), 4) | ||
}) | ||
``` | ||
|
||
Example configuration file can be downloaded from [examples/mail.js](examples/mail.js), and should be kept inside `config/mail.js`. | ||
Now since the `add` method has a bug, it will return `6` instead of `4`. But the build will pass. | ||
|
||
[appveyor-image]: https://img.shields.io/appveyor/ci/thetutlage/adonis-mail/master.svg?style=flat-square | ||
|
||
[appveyor-url]: https://ci.appveyor.com/project/thetutlage/adonis-mail | ||
|
||
[Official Documentation](http://adonisjs.com/docs/mail) | ||
[npm-image]: https://img.shields.io/npm/v/@adonisjs/mail.svg?style=flat-square | ||
[npm-url]: https://npmjs.org/package/@adonisjs/mail | ||
|
||
## <a name="contribution-guidelines"></a>Contribution Guidelines | ||
[travis-image]: https://img.shields.io/travis/adonisjs/adonis-mail/master.svg?style=flat-square | ||
[travis-url]: https://travis-ci.org/adonisjs/adonis-mail | ||
|
||
In favor of active development we accept contributions for everyone. You can contribute by submitting a bug, creating pull requests or even improving documentation. | ||
[coveralls-image]: https://img.shields.io/coveralls/adonisjs/adonis-mail/develop.svg?style=flat-square | ||
|
||
You can find a complete guide to be followed strictly before submitting your pull requests in the [Official Documentation](http://adonisjs.com/docs/2.0/contributing). | ||
[coveralls-url]: https://coveralls.io/github/adonisjs/adonis-mail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
environment: | ||
matrix: | ||
- nodejs_version: 'Stable' | ||
- nodejs_version: '7' | ||
|
||
init: | ||
git config --global core.autocrlf true | ||
|
||
install: | ||
- ps: Install-Product node $env:nodejs_version | ||
- npm install | ||
|
||
test_script: | ||
- node --version | ||
- npm --version | ||
- npm run test:win | ||
|
||
build: off | ||
clone_depth: 1 | ||
|
||
matrix: | ||
fast_finish: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use strict' | ||
|
||
/* | ||
* adonis-framework | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
const semver = require('semver') | ||
const { spawn } = require('child_process') | ||
const spawnArgs = [] | ||
|
||
if (semver.lt(process.version, '8.0.0')) { | ||
spawnArgs.push('--harmony-async-await') | ||
} | ||
|
||
function local () { | ||
spawnArgs.push('./node_modules/.bin/japa') | ||
const tests = spawn('node', spawnArgs) | ||
tests.stdout.on('data', (data) => process.stdout.write(data)) | ||
tests.stderr.on('data', (data) => process.stderr.write(data)) | ||
tests.on('close', (code) => process.exit(code)) | ||
} | ||
|
||
function win () { | ||
spawnArgs.push('./node_modules/japa-cli/index.js') | ||
const tests = spawn('node', spawnArgs) | ||
tests.stdout.on('data', (data) => process.stdout.write(data)) | ||
tests.stderr.on('data', (data) => process.stderr.write(data)) | ||
tests.on('close', (code) => process.exit(code)) | ||
} | ||
|
||
if (process.argv.indexOf('--local') > -1) { | ||
local() | ||
} else if (process.argv.indexOf('--win') > -1) { | ||
win() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
'use strict' | ||
|
||
const Env = use('Env') | ||
|
||
module.exports = { | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Connection | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Connection to be used for sending emails. Each connection needs to | ||
| define a driver too. | ||
| | ||
*/ | ||
connection: Env.get('MAIL_CONNECTION', 'smtp'), | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| SMTP | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Here we define configuration for sending emails via SMTP. | ||
| | ||
*/ | ||
smtp: { | ||
driver: 'smtp', | ||
pool: true, | ||
port: 2525, | ||
host: '', | ||
secure: false, | ||
auth: { | ||
user: Env.get('MAIL_USERNAME'), | ||
pass: Env.get('MAIL_PASSWORD') | ||
}, | ||
maxConnections: 5, | ||
maxMessages: 100, | ||
rateLimit: 10 | ||
}, | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| SparkPost | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Here we define configuration for spark post. Extra options can be defined | ||
| inside the `extra` object. | ||
| | ||
| https://developer.sparkpost.com/api/transmissions.html#header-options-attributes | ||
| | ||
| extras: { | ||
| campaign_id: 'sparkpost campaign id', | ||
| options: { // sparkpost options } | ||
| } | ||
| | ||
*/ | ||
sparkpost: { | ||
driver: 'sparkpost', | ||
apiKey: Env.get('SPARKPOST_API_KEY'), | ||
extras: {} | ||
} | ||
} |
Oops, something went wrong.