errormailer
v3.0.1
Published
Sending email for each error in your node app was never easier! It supports connect and express.
Downloads
37
Readme
node-errormailer
Sending email for each error must be easy! The most basic form of error notification is sending an email for each error, and it must be super-easy to set up in node applications.
Usage
errormailer is based upon the awesome Nodemailer, so you will have to configure it before usage.
var nodemailer = require("nodemailer");
var errormailer = require("errormailer");
// create reusable transport method (opens pool of SMTP connections)
var transport = nodemailer.createTransport("SMTP",{
service: "Gmail",
auth: {
user: "[email protected]",
pass: "userpass"
}
});
var errorHandler = errormailer(transport, {
subject: "Testing errormailer!",
to: "[email protected]"
});
errorHandler("this is an error!");
Option sendAlways
Currently error emails are only sent for production environments. But if you want it to send always, use the option sendAlways
. There is also an option ignore
where you can specify your own logic when to ignore an error to be sent, for example:
var errorHandler = errormailer(transport, {
subject: "Testing errormailer!",
to: "[email protected]",
ignore: function(errorToBeSent) {
// any errors won't be sent that have a code && it's below 400
return errorToBeSent.code && errorToBeSent.code < 400;
}
});
Option debugProperties
Sometimes error objects come with unusual properties you'd like to see in the error mail. Just set debugProperties
to true to get them all in the error mail. This can be useful if you want to inspect errors deeper.
var errorHandler = errormailer(transport, {
subject: "Enable debug mode",
to: "[email protected]",
debugProperties: true
});
Custom output
If you pass an genuine Error object onto errormailer, then toString()
will be called to retrieve the error message. Like that, this enables the develope to customize the message output by overriding toString()
in an error sub class.
Connect/Express support
errormailer fully supports Connect and Express, just use the
built function (errorHandler
in the previous example) as a middleware.
See this (Example)
for more details.
Install
npm install nodemailer --save
npm install node-errormailer --save
Examples
errormailer supports:
- node standard callback system (Example);
- connect and express (Example);
- the Domain object, for better error handling in node (Example);
Contributing to node-errormailer
- Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
- Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
- Fork the project
- Start a feature/bugfix branch
- Commit and push until you are happy with your contribution
- Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
- Please try not to mess with the Makefile and package.json. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
HTML email template license
The html email template it is based on MailChimp's email blueprints: https://github.com/mailchimp/Email-Blueprints
The html email template is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License: http://creativecommons.org/licenses/by-sa/3.0/
Contributors
- Matteo Collina (Original Creator)
- Michael Heuberger
LICENSE - "MIT License"
Copyright (c) 2013-2018 Matteo Collina, http://matteocollina.com Michael Heuberger, https://binarykitchen.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.