/ Ghost

Configuring Mandrill mail service for Ghost

After installing Ghost, you will be gently prompted to set up a mail service and you will be redirected to Ghost documentation with details how to configure it. Although currently it is used only for resetting a password, it still might be helpful set it up in case you need it. And also in the future, it might be used for other features.

The official documentation mentions Mailgun and Gmail configurations. Both are fine but I had already very good experience with Mandrill and also Mandrill is very well rated in reviews so I have decided to go with it.

Configuring

First thing you need to do is modify your config.js in your Ghost repository and once you are done with changes, you need to deploy it.

mail: {
    transport: 'SMTP',
    options: {
        host: 'smtp.mandrillapp.com',
        service: 'Mandrill',
        port: 587,
        auth: {
            user: process.env.MANDRILL_USERNAME,
            pass: process.env.MANDRILL_PASSWORD'
        }
    }
},

Personally, I prefer to keep the configuration variables outside the config so they can easily be changed without redeploying the application and also they are protected against whoever gets an access to the code.

OpenShift has for this environment variables that allows you to store these values out of your code. Setting these variables with OpenShift is really easy. Assuming you have installed command line tools for OpenShift, you can run two commands from Terminal with your values. You can also make it even more configurable and store also the host, service, port in the variables.

$ rhc env set MANDRILL_USERNAME=<your username> -a <your app name>
$ rhc env set MANDRILL_PASSWORD=<your API key> -a <your app name>

Once you are done with the configuration. You can easily verify the configuration by going into the Admin -> Settings -> Labs and after that sending a test email.

Tomáš Linhart

Tomáš Linhart

Principal iOS Engineer at Lesson Nine GmbH • Swift & iOS and Mac lover and enthusiast •  • A bit .NET, Android lover...

Read More