Install from npm
npm install nodemailer-trap-plugin --save
var trap = require('nodemailer-trap-plugin').trap;
nodemailerTransport.use('compile', trap(options))
Where options
- to - the email address used to send emails to. Default:
''
- subject - the subject formatted. Default:
'[DEBUG] - To: {0}, Subject: {1}'
- passthrough - the regex / string / function to passthrough emails without modification (It works only for single recipient). Default:
false
.
var nodemailer = require('nodemailer');
var trap = require('nodemailer-trap-plugin').trap;
var transporter = nodemailer.createTransport();
transporter.use('compile', trap({
to: 'admin@example.org',
passthrough: '@domain.com'
}));
// first email
transporter.sendMail({
from: 'noreply@example.org',
to: 'john.doe@example.com',
subject: 'Hello John'
});
// second email
transporter.sendMail({
from: 'noreply@example.org',
to: 'jane@domain.com',
subject: 'Hello Jane'
});
The first email has been sent to admin@example.org
with subject "[DEBUG] - To: john.doe@example.com, Subject: john.doe@example.com"
The second email has been delivered to recipient without modifications because to
field is satisfied options.passthrough
var nodemailer = require('nodemailer');
var trap = require('nodemailer-trap-plugin').trap;
var transporter = nodemailer.createTransport();
transporter.use('compile', trap({
to: 'admin@example.org',
passthrough: '@domain.com'
}));
var nodemailer = require('nodemailer');
var trap = require('nodemailer-trap-plugin').trap;
var transporter = nodemailer.createTransport();
transporter.use('compile', trap({
to: 'admin@example.org',
passthrough: /.*?@domain\.com/
}));
var nodemailer = require('nodemailer');
var trap = require('nodemailer-trap-plugin').trap;
var transporter = nodemailer.createTransport();
transporter.use('compile', trap({
to: 'admin@example.org',
passthrough: function (toAddress) {
return toAddress.indexOf('@domain.com') > -1;
}
}));
See the CHANGELOG.
See the list of project's contributors!
The MIT License (MIT)
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.