egg-mailgun
Mailgun Plugin for egg.
This plugin based on mailgun-js, if you want to know specific usage, you should refer to the document of mailgun-js.
Install
$ npm i egg-mailgun --save
Usage
// {app_root}/config/plugin.jsexportsmailgun = enable: true package: 'egg-mailgun';
Configuration
// {app_root}/config/config.default.jsexportsmailgun = client: // api key apiKey: 'your api key' // domain domain: 'your domain name' // load into app, default is open app: true // load into agent, default is close agent: false;
see config/config.default.js for more detail.
Example
Sending Messages
use mailgun api at controller:
// {app_root}/app/controller/email.jsconst Controller = Controller; async { const data = from: 'Excited User <me@samples.mailgun.org>' to: 'bar@example.com, YOU@YOUR_DOMAIN_NAME' subject: 'Hello' text: 'Testing some Mailgun awesomness!' ; thisctxbody = await thisappmailgun; } moduleexports = EmailController;
Questions & Suggestions
Please open an issue here.