Package Exports
- strapi-provider-email-mock
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (strapi-provider-email-mock) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
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: 'strapi@example.com',
defaultReplyTo: 'strapi@example.com',
},
},
});
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 = 'foo@example.com';
const sender = 'bar@example.com';
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();
});