Magic-Mail — Installation
Prerequisites
- Strapi v5.0.0 or higher (v4 is not supported)
- Node.js 18.x, 20.x, or 22.x
- Database: SQLite, PostgreSQL, MySQL, or MariaDB (any Strapi-supported database)
- npm 8+ or yarn 1.22+
1. Install the package
npm install strapi-plugin-magic-mailyarn add strapi-plugin-magic-mailpnpm add strapi-plugin-magic-mail2. Enable in your Strapi config
Edit (or create) config/plugins.ts:
export default () => ({
'magic-mail': {
enabled: true,
},
});That is the minimum. All runtime configuration (accounts, routing rules, templates) lives in the admin UI and is stored in your database.
3. Rebuild the admin panel
npm run build
npm run developThe first npm run develop after install will run migrations and create the necessary tables.
4. Add your first email account
- Open Strapi admin (typically
http://localhost:1337/admin). - In the sidebar click Magic-Mail → Email Accounts.
- Click Add Account.
- Pick a provider (Gmail OAuth, SMTP, SendGrid, etc.) — see Providers for per-provider setup.
- Fill in the credentials and click Test.
- Once the test passes, click Save. The account becomes immediately available to the email service.
5. (Recommended) Set an encryption key
Without a custom key, Magic-Mail uses Strapi's default encryption. For production, generate your own:
openssl rand -hex 32Add the output to your .env:
MAGIC_MAIL_ENCRYPTION_KEY=your-64-character-hex-outputRestart Strapi. From now on all new credentials are encrypted with this key. Do not change this key after adding accounts — existing credentials will become undecryptable.
Advanced configuration
All options are optional. The plugin ships with safe defaults.
// config/plugins.ts
export default () => ({
'magic-mail': {
enabled: true,
config: {
// Custom encryption key (recommended for production)
encryptionKey: process.env.MAGIC_MAIL_ENCRYPTION_KEY,
// Verbose logging — useful during development
debug: process.env.NODE_ENV === 'development',
// Global rate-limit settings (individual accounts can override)
rateLimit: {
enabled: true,
window: 3600, // seconds
maxRequests: 100,
},
// Optional: pin a default sender address. Used when the
// caller does not supply `from`.
defaultFrom: 'noreply@example.com',
},
},
});Environment variables (optional)
# Custom encryption key for credentials at rest
MAGIC_MAIL_ENCRYPTION_KEY=your-32-byte-hex-key
# Enable verbose Magic-Mail logs
DEBUG=magic-mail:*
# Redis connection for shared rate-limit tracking (multi-instance deployments)
REDIS_URL=redis://localhost:6379Verify installation
Check the admin panel sidebar for the Magic-Mail entry. Under Email Accounts you should see the accounts list (empty initially).
You can also verify from code:
// Anywhere in your Strapi project
const emailRouter = strapi.plugin('magic-mail').service('email-router');
console.log(typeof emailRouter.send); // 'function'Installing alongside other plugins
Magic-Mail works seamlessly with:
- Magic-Link — uses Magic-Mail for authentication emails.
- strapi-plugin-email-designer-5 — optional visual designer.
Install them together:
npm install strapi-plugin-magic-mail strapi-plugin-magic-link-v5export default () => ({
'magic-mail': { enabled: true },
'magic-link': { enabled: true },
});Troubleshooting install errors
If the plugin does not appear in the sidebar after npm run develop:
rm -rf .cache node_modules/.cache dist
npm run build
npm run developFor peer-dependency warnings:
npm install --legacy-peer-depsSee Troubleshooting for more.