ember-cli-mandrill
v0.2.0
Published
Mandrill API for Ember.js web apps.
Downloads
6
Maintainers
Readme
ember-cli-mandrill
This addon is the drop-in-and-use client implementation of Mandrill API for Ember.js. It integrates the service into your Ember.js web app which is proxying to the Mandrill and allows you to query for data with native-like API objects.
Installation
ember install ember-cli-mandrill
Initial Configuration
After installation, you need to configurate Mandrill client to do connection and access the API.
In your config/environment.js file add and edit:
ENV['mandrill'] = {
api: {
host: 'https://mandrillapp.com/api/1.0/',
key: 'YOUR_API_KEY_HERE'
},
smtp: {
host: 'smtp.mandrillapp.com',
port: 587,
username: 'YOUR_USERNAME',
password: 'YOUR_PASSWORD'
}
};
Addon API and How-to-Use
Currently, only Users Calls API and Messages Calls API are fully implemented. All methods return a Promise, so you can do this:
this.mandrill.send(newEmail).then(function(response) {
alert('Email sent!' + response);
});
The list of available actions:
PAY ATTENTION: You don't need to pass your API key to any of the methods!
What objects to pass to corresponding methods and how do they look, you should directly look up on Messages Calls API.
Users Calls API methods
These are the addon methods that are proxying to Users Calls Mandrill API.
getUserInfo()
Returns you information about the current API user. Accepts no parameters. Proxying to Users#info Mandrill API method.
this.mandrill.getUserInfo().then(function(response) {
//do whatever you want with 'response' object
});
userPing()
Validates an API key and respond to a ping. Accepts no parameters. Proxying to Users#ping Mandrill API method.
this.mandrill.userPing().then(function(response) {
//do whatever you want with 'response' object
});
userPing2()
Validates an API key and respond to a ping (analogous JSON parser version). Accepts no parameters. Proxying to Users#ping2 Mandrill API method.
this.mandrill.userPing2().then(function(response) {
//do whatever you want with 'response' object
});
userSenders()
Returns the senders that have tried to use this account, both verified and unverified. Accepts no parameters. Proxying to Users#senders Mandrill API method.
this.mandrill.userSenders().then(function(response) {
//do whatever you want with 'response' object
});
Messages Calls API methods
These are the addon methods that are proxying to Messages Calls Mandrill API.
send()
Sends a new transactional email. Accepts email object as a parameter. Proxying to Messages#send Mandrill API method.
this.mandrill.send(newEmail).then(function(response) {
//do whatever you want with 'response' object
});
sendTemplate()
Sends a new transactional email using a template. Accepts email object as a parameter. Proxying to Message#send-template Mandrill API method.
this.mandrill.sendTemplate(newEmail).then(function(response) {
//do whatever you want with 'response' object
});
search()
Searches recently sent messages and optionally narrow by date range, tags, senders, and API keys. Accepts query object as a parameter. Proxying to Messages#search Mandrill API method.
this.mandrill.search(query).then(function(response) {
//do whatever you want with 'response' object
});
getEmailInfo()
Gets the information for a single recently sent message. Accepts email id as a parameter. Proxying to Messages#info Mandrill API method.
this.mandrill.getEmailInfo(5).then(function(response) {
//do whatever you want with 'response' object
});
getEmailContent()
Gets the full content of a recently sent message. Accepts email id as a parameter. Proxying to Messages#content Mandrill API method.
this.mandrill.getEmailContent(7).then(function(response) {
//do whatever you want with 'response' object
});
parseEmail()
Parses the full MIME document for an email message, returning the content of the message broken into its constituent pieces. Accepts raw email object as a parameter. Proxying to Messages#parse Mandrill API method.
this.mandrill.parseEmail(raw).then(function(response) {
//do whatever you want with 'response' object
});
sendRawEmail()
Takes a raw MIME document for a message, and send it exactly as if it were sent through Mandrill's SMTP servers. Accepts email object as a parameter. Proxying to Messages#send-raw Mandrill API method.
this.mandrill.sendRawEmail(email).then(function(response) {
//do whatever you want with 'response' object
});
listScheduled()
Queries your scheduled emails. Accepts recipient string as a parameter. Proxying to Messages#list-scheduled Mandrill API method.
this.mandrill.listScheduled(recipient).then(function(response) {
//do whatever you want with 'response' object
});
cancelScheduled()
Cancels a scheduled email. Accepts email id as a parameter. Proxying to Messages#cancel-scheduled Mandrill API method.
this.mandrill.cancelScheduled(9).then(function(response) {
//do whatever you want with 'response' object
});
reschedule()
Reschedules a scheduled email. Accepts query object as a parameter. Proxying to Messages#reschedule.
this.mandrill.cancelScheduled(query).then(function(response) {
//do whatever you want with 'response' object
});
Running Tests
ember test
ember test --server
Building
ember build
For more information on using ember-cli, visit http://www.ember-cli.com/.