Help configuring parse-server-api-mail-adapter via configuration.json

Hi All,

I run parse-server on Kubernetes via the stock docker image. I configure it via custom configuration.json. I am trying to figure out how to specify parse-server-api-mail-adapter in configuration.json - seems like the example installation doesn’t include that case. Do I create a separate .js file for my custom initialization of the adapter and then specify that in configuration.json… any tips?


Hi @evtimDev,

I’m not sure if I’m understanding you 100%, so forgive me if not.

I don’t think you’ll be able to do that, because of the callback’s that form part of the configuation.

This is what I do - hopefully it’s of some use to you.

I have a configuration.js file that lives in the src dir of my project. It makes use of the dotenv and convict packages for loading in all my environment variables:

const path = require("path");

require("dotenv").config({ path: path.join(__dirname, "../.env") });

const convict = require("convict");

const config = convict({
    env: {
        doc: "The application environment",
        format: ["development", "staging", "production"],
        default: "development",
        env: "NODE_ENV"
    AWS: {
        sesVerifiedDomain: "",
        sesUri: "",
        s3ImageBucket: {
            doc: "S3 bucket for images",
            format: String,
            default: "mybucket"
        accessKeyId: {
            doc: "AWS Access Key ID",
            format: String,
            default: "",
            env: "AWS_ACCESS_KEY_ID"
        secretAccessKey: {
            doc: "AWS Secret Access Key",
            format: String,
            default: "",
            env: "AWS_SECRET_ACCESS_KEY"
        region: {
            doc: "AWS Region",
            format: String,
            default: "",
            env: "AWS_REGION"

config.loadFile(path.join(__dirname, "../config/" + config.get("env") + ".json"));

module.exports = config.getProperties();

Then, in my server.js file, I load in my config file as per the below and use the config in my app setup:

const config = require("./src/configuration");

const parseApi = new ParseServer({
    databaseURI: config.parse.dbUri,
    serverURL: `${config.parse.serverUrl}/parse`,
    publicServerURL: `${config.parse.serverUrl}/parse`,
    masterKey: config.parse.masterKey,
    appId: config.parse.appId,
    emailAdapter: {
        module: "parse-server-api-mail-adapter",
        options: {
            // The email address from which emails are sent.
            sender: config.mail.fromAddress,

I hope this is at least somewhat helpful!?

@woutercouvaras Thank you for the info, this was helpful!

I ended up creating a subclass adapter that implements the callbacks as needed and then I specify that as the email adapter in config.json. This makes for a cleaner solution and doesn’t introduce the risk of things breaking if the stock parse-server docker image changes in the future in an incompatible way (our docker image is based off the stock one currently).

  1. Create cloud/adapters/email/mailgunAdapter.js and keep it with the rest of the cloud code:
const Mailgun = require('mailgun.js');
const formData = require('form-data');
const { ApiPayloadConverter, ApiMailAdapter } = require('parse-server-api-mail-adapter');

// Configure mail client
const mailgun = new Mailgun(formData);
const mailgunClient = mailgun.client({ username: 'api', key: process.env.MAILGUN_API_KEY });
const mailgunDomain = process.env.MAILGUN_DOMAIN;

class MailgunApiMailAdapter extends ApiMailAdapter {
     * Creates a new mail adapter.
     * @param {Object} options The configuration options.
    constructor(options) {
        options['apiCallback'] = async ({ payload, locale }) => {
            const mailgunPayload = ApiPayloadConverter.mailgun(payload);
            await mailgunClient.messages.create(mailgunDomain, mailgunPayload);

        // Initialize

module.exports = MailgunApiMailAdapter;

  1. specify the adapter via PARSE_SERVER_EMAIL_ADAPTER env variable (or can be done via config.json as well) like this:
  "module": "../../cloud/adapters/email/mailgunAdapter.js",
  "options": {

1 Like