-
-
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.
feat(instructions): add instructions for
adonis install
- Loading branch information
1 parent
94b20f2
commit 83cc8d0
Showing
4 changed files
with
113 additions
and
0 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,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: {} | ||
} | ||
} |
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,21 @@ | ||
'use strict' | ||
|
||
/* | ||
* adonis-mail | ||
* | ||
* (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 path = require('path') | ||
|
||
module.exports = async (cli) => { | ||
try { | ||
await cli.copy(path.join(__dirname, 'examples/config.js'), path.join(cli.helpers.configPath(), 'mail.js')) | ||
cli.command.completed('create', 'config/mail.js') | ||
} catch (error) { | ||
console.log(error) | ||
} | ||
} |
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,28 @@ | ||
## Registering provider | ||
|
||
The provider is registered inside `start/app.js` file under `providers` array. | ||
|
||
```js | ||
const providers = [ | ||
'@adonisjs/mail/providers/MailProvider' | ||
] | ||
``` | ||
|
||
That's all! Now you can use the mail provider as follows. | ||
|
||
```js | ||
const Mail = use('Mail') | ||
|
||
await Mail.send('emails.welcome', {}, (message) => { | ||
message.from('foo@bar.com') | ||
message.to('bar@baz.com') | ||
}) | ||
``` | ||
|
||
The `welcome` is the view name stored inside the `resources/views/emails` directory. | ||
|
||
## Configuration and Environment variables | ||
|
||
The configuration file is saved as `config/mail.js`, feel free to tweak it according. | ||
|
||
Also make sure to define sensitive driver details inside the `.env` file and reference them via `Env` provider. |
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