strapi-provider-email-mock
v1.0.1
Published
A simple in-memory mock mail provider for strapi.io
Readme
strapi-provider-email-mock
A simple in-memory mock mail provider for strapi.io
Usage
Setup in plugins.js like any other provider:
module.exports = ({env}) => ({
email: {
provider: 'mock',
providerOptions: {},
settings: {
// If set to false, each email sent will be logged to console
quiet: true,
defaultFrom: '[email protected]',
defaultReplyTo: '[email protected]',
},
},
});Each mail sent gets pushed on the recipient's stack and can be retrieved via .popMail(...) as follows:
const email = require('strapi-provider-email-mock');
test('send email to provider', async done => {
// send mail
const recipient = '[email protected]';
const sender = '[email protected]';
await strapi.plugins['email'].services.email.send({
to: recipient,
from: sender,
subject: 'Test',
text: 'You may safely delete this mail.',
});
// pop off the recipient's personal mail stack
const mail = email.popMail(recipient);
if (!mail) fail('No mail received.')
expect(mail.text).toContain('delete this');
done();
});