Parse Server API Mail Adapter

5.0.5 · active · verified Sun Apr 19

The `parse-server-api-mail-adapter` provides a universal email solution for Parse Server, enabling it to send emails via any third-party REST API. It supports dynamic templates, localization, and includes out-of-the-box integrations for services like AWS SES, Mailgun, and ZeptoMail, along with a custom API option. The current stable version is 5.0.5, with frequent maintenance releases for security updates and occasional minor/major releases for new features or Node.js version support. Its key differentiators include its extensibility to any REST API-based mail service, built-in templating, and full localization support, making it a flexible choice compared to adapters tied to specific providers. It ships with TypeScript definitions, enhancing developer experience for TypeScript users.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to configure `parse-server-api-mail-adapter` with Parse Server using environment variables for sensitive data and Mailgun as an example provider, including template paths.

import ParseServer from 'parse-server';
import Mailgun from 'mailgun.js';
import formData from 'form-data';

const mailgun = new Mailgun(formData);
const mailgunClient = mailgun.client({ username: 'api', key: process.env.MAILGUN_API_KEY ?? '' });
const mailgunDomain = process.env.MAILGUN_DOMAIN ?? 'your-mailgun-domain.com';

// Basic Parse Server setup
const server = new ParseServer({
    databaseURI: process.env.DATABASE_URI ?? 'mongodb://localhost:27017/dev',
    cloud: __dirname + '/cloud/main.js', // Or wherever your cloud code is
    appId: process.env.APP_ID ?? 'myAppId',
    masterKey: process.env.MASTER_KEY ?? 'myMasterKey',
    serverURL: process.env.SERVER_URL ?? 'http://localhost:1337/parse',
    publicServerURL: process.env.PUBLIC_SERVER_URL ?? 'http://localhost:1337/parse',

    // Configure the Mail Adapter
    emailAdapter: {
        module: 'parse-server-api-mail-adapter',
        options: {
            sender: process.env.MAIL_SENDER ?? 'noreply@example.com',
            templates: {
                passwordReset: {
                    subject: 'Reset Your Password',
                    pathPlainText: 'path/to/templates/password_reset.txt',
                    pathHtml: 'path/to/templates/password_reset.html'
                },
                emailVerification: {
                    subject: 'Verify Your Email',
                    pathPlainText: 'path/to/templates/email_verification.txt',
                    pathHtml: 'path/to/templates/email_verification.html'
                }
            },
            // Example for Mailgun provider
            api: {
                mailgun: {
                    domain: mailgunDomain,
                    client: mailgunClient,
                    options: {
                        // Custom options for Mailgun API calls
                    }
                }
            }
            // Other API providers like AWS SES, ZeptoMail or custom API would be configured here
        }
    }
});

// To run Parse Server (for example in index.js)
// const app = express();
// app.use('/parse', server.app);
// const port = process.env.PORT || 1337;
// app.listen(port, () => console.log(`Parse Server running on port ${port}.`));

view raw JSON →