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:
- Set up a SparkPost account and verify your sending domain.
- Go to SparkPost Accounts –> SMTP Relay and copy the host, port and username.
- 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.
- 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.