Sending emails from Ghost with Nodemailer and SparkPost

While I personally prefer Jekyll to Ghost in the battle of minimalistic CMS platforms, I recently set up a Ghost blog for work and connected the built-in Nodemailer email module with SparkPost, an email service. Here’s how:

  1. Set up a SparkPost account and verify your sending domain.
  2. Go to SparkPost Accounts –> SMTP Relay and copy the host, port and username.
  3. Under Accounts –> API Keys, select the Send via SMTP permission and generate a new API key. The generated API key will be your SMTP password.
  4. Open up your Ghost blog’s config.js, and modify the production section.
  production: {
    url: 'https://example.com/blog',
    mail: {
      from: '"Example.com Blog" <no-reply@example.com>',
      transport: 'SMTP',
      options: {
        host: 'smtp.sparkpostmail.com',
        port: 587,
        auth: {
          user: 'SPARKPOST_SMTP_USERNAME',
          pass: 'SPARKPOST_SMTP_API_KEY'
        }
      }
    },
    database: {
    ....
    }
  }

You can test your configuration by inviting someone to your Ghost installation. The invitee should receive an email from Example.com blog.

Tags: node.js ghost
comments powered by Disqus