How to configure mail for Ghost Blog

In this post:

Ghost needs additional setting after installation in order to send emails - for password resets, user invitations, system notifications, and other features. Ghost uses Nodemailer. You have two option using Direct Mail service or configuring an external mail service will generally be more reliable.

If you see this yellow warning message:

Ghost is currently unable to send email. See http://support.ghost.org/mail for instructions.

Then you need to configure your mail in order to reset your password or to send invitation to your team.

Mail configuration for Ghost 1.0

Ghost 1.0 is the last major version from the popular blog which introduced several big updates. The mail configuration is not change in this version but here you will find steps how to configure your ghost mail with mailgun:

  • Log on your server
  • locate your installation folder
    • for example - /var/www/blog.myblog.com
  • open with your favorite editor file: config.production.json
  • find and comment old mail configuration:
  "mail": {
    "transport": "Direct"
  },

coment out this section by:

 // "mail": {
 //   "transport": "Direct"
 // },

and add this new section(you need to change the user and pass for your account):

"mail": {
        	"transport": 'SMTP',
	        "options": {
        	    "service": 'Mailgun',
	            "auth": {
        	        "user": 'postmaster@XXXXX.mailgun.org',
	                "pass": 'XXXXXXX'
        	    }
	        }
	    }

for mailgun setup you can check sections: Configure Ghost External mail and

SMTP Mailgun settings for Ghost Blog additional setup

Direct Mail service

This method is by default and you can see message like after installation:

In the terminal used for starting Ghost, the process should display a WARNING message:

WARNING: Ghost is attempting to use a direct method to send email.
It is recommended that you explicitly configure an email service.

In general default Ghost settings will attempt to use the command line program, sendmail.

which sendmail

expected result:

/usr/sbin/sendmail

In case of nothing you don't have setup mail on your server.

We are not going to have a look on this solution since:

Direct can be quite inefficient as it queues all e-mails to be sent into memory. Additionally, if a message is not yet sent and the process is closed, all data about queued messages are lost. Thus direct is only suitable for low throughput systems, like password remainders and such, where the message can be processed immediatelly.

External mail - recommended

Choose your Service provider

  • Gmail - perfect for personal blogs
  • Hotmail
  • Mailgun - recomemded by ghost team
  • SendGrid
  • Yahoo
  • yandex

Configure your ghost installtion

Depending on your installation and version you can have a bit different process of installation.

  • find your ghost installation folder

  • Find file: config.js or config.production.json

  • do a copy - just in case

cp config.js config.js.back
  • open the file: config.js
sudo nano config.js
  • find section:
production: { 
 url: 'http://my-ghost-blog.com',
 mail: {},
 database: {
  • add your settings:
  • gmail
"mail": {
            "service": 'Gmail',
            "transport": 'SMTP',
            "options": {
                "host": 'smtp.gmail.com',
                "port": 465,
                "secureConnection": true,
                "auth": {
                    "user": 'XXXXXXX@gmail.com',
                    "password": 'XXXXXXXXX'
                }
            }
        }
  • mailgun
"mail": {
      "transport": "SMTP",
      "options": {
           "service": "Mailgun",
           "auth": {
                "user": "postmaster@mail.example.com",
                "pass": "XXXXXXXXXX"
                }
           }
 },

So your final config file should look like:

production: { 
 url: 'http://my-ghost-blog.com',
"mail": {
      "transport": "SMTP",
      "options": {
           "service": "Mailgun",
           "auth": {
                "user": "postmaster@mail.example.com",
                "pass": "XXXXXXXXXX"
                }
           }
 },
 database: {
  • close and save
  • restart your ghost in order to apply settings

SMTP GMail settings for Ghost Blog additional setup

Working with Gmail, we should:

  • enable the IMAP
  • Enable less secure apps

Enable IMAP

  • After login to Gmail account
  • Go to Settings Gear (next to Gmail Profile Image in the right up corner)
  • go to settings
  • Go to Forwarding
  • Find POP/IMAP section
  • Enable IMAP and click Save Changes

Enable less secure apps

  • Go to Third party authorization permission
  • Open Less secure section
  • Turn on Enable less secure apps

SMTP Mailgun settings for Ghost Blog additional setup

More information you can find here: Where can I find my API key and SMTP credentials?

  • Register a new account on Mailgun.com ( Free plan is by default )
  • Verify your Email

Domain types

  • Sandbox - Sandbox domains are restricted to authorized recipients only
  • So in order to send mail you need to:
  • Open sandbox domain
  • go to Authorized Recipients
  • Manage Authorized Recipients
  • Invite new recipient
  • get Default SMTP Login
  • get Default Password
  • put them in your json configuration:
           "service": "Mailgun",
           "auth": {
                "user": "postmaster@mail.example.com",
                "pass": "XXXXXXXXXX"
                }

Verified sending domains

  • create subdomain for sending email
  • verify it
  • Now open your Verified sending domains
  • you can get your SMPT credits on the “Domain Information.”
  • Replace postmaster@mail.example.com and XXXXXXXXX with your Mailgun SMPT username and Password.

Test mail configuration

  • Now login to your Admin Dashboard
  • my domain : domain.com/ghost/
  • Go to Team
  • Send invitation mail
    or
  • Labs
  • Send test mail
  • In case of error you will have red alert in the top of your screen:

Error: Message could not be sent More info: Can't send mail

Conclusion

Ghost has an easy to configure mails for production. It’s a free and open source software which in combination with free mail is powerful blogger tool. In this tutorial, we have shown how to configure basic mail service using Ubuntu 16.04 and gmail / mailgun as your web server.

Update: It seems that new Ghost Blog is checking the config file for valid format. So if you forget to add the quotation marks for your mail section you will get error invalid config. So always be sure to add quotations to your attributes. more for this error here:

Ghost Blof error validating config

Related Article