# Help using Gmail with Docker Ghost

**URL:** <https://forum.ghost.org/t/help-using-gmail-with-docker-ghost/41404>\
**Category:** Self-hosting\
**Created:** [September 22, 2023, 2:14pm UTC](https://forum.ghost.org/t/help-using-gmail-with-docker-ghost/41404 "2023-09-22T14:14:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shaftspanner](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@shaftspanner](https://forum.ghost.org/u/shaftspanner)\
**Post date:** [September 22, 2023, 2:14pm UTC](https://forum.ghost.org/t/help-using-gmail-with-docker-ghost/41404/1 "2023-09-22T14:14:07Z")

</div>

I’m trying to setup gmail for transactional emails on my blog but I keep hitting errors. I’m using Ghost 5.55.0 and MySQL 8 running in docker 24.0.6 on Ubuntu 22.04.

My docker configuration is here: [Ghost Docker compose - Pastebin.com](https://pastebin.com/7VVNQ0Y4)

When I try to sign up for a user account, I get an error in the interface saying “Failed to send magic link email” and the logs show the following error:

```auto
[2023-09-22 12:58:03] ERROR "POST /members/api/send-magic-link/" 500 8469ms

Failed to send email. Reason: Sending failed.

"Please see https://ghost.org/docs/config/#mail for instructions on configuring email."

Error ID:
    aad3c760-5947-11ee-a9af-03e019494d5f

----------------------------------------

Error: Sending failed
    at createMailError (/var/lib/ghost/versions/5.55.0/core/server/services/mail/GhostMailer.js:68:12)
    at DirectMailer.<anonymous> (/var/lib/ghost/versions/5.55.0/node_modules/nodemailer-direct-transport/lib/direct-transport.js:157:41)
    at DirectMailer.<anonymous> (/var/lib/ghost/versions/5.55.0/node_modules/nodemailer-direct-transport/lib/direct-transport.js:228:30)
    at /var/lib/ghost/versions/5.55.0/node_modules/nodemailer-direct-transport/lib/direct-transport.js:350:28
    at callback (/var/lib/ghost/versions/5.55.0/node_modules/smtp-connection/lib/smtp-connection.js:374:14)
    at SMTPConnection.<anonymous> (/var/lib/ghost/versions/5.55.0/node_modules/smtp-connection/lib/smtp-connection.js:385:20)
    at SMTPConnection._actionMAIL (/var/lib/ghost/versions/5.55.0/node_modules/smtp-connection/lib/smtp-connection.js:1252:16)
    at SMTPConnection.<anonymous> (/var/lib/ghost/versions/5.55.0/node_modules/smtp-connection/lib/smtp-connection.js:759:14)
    at SMTPConnection._processResponse (/var/lib/ghost/versions/5.55.0/node_modules/smtp-connection/lib/smtp-connection.js:669:16)
    at SMTPConnection._onData (/var/lib/ghost/versions/5.55.0/node_modules/smtp-connection/lib/smtp-connection.js:493:10)
    at TLSSocket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:315:12)
    at readableAddChunk (node:internal/streams/readable:289:9)
    at TLSSocket.Readable.push (node:internal/streams/readable:228:10)
    at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23)

[2023-09-22 13:07:39] INFO Worker for job "mentions-email-report" online
[2023-09-22 13:07:39] INFO Worker for job mentions-email-report sent a message: done

```

I’m sure there’s a really simple error in my configuration, but I can’t for the life of me find what it is!  
type or paste code here

```auto

```

---

<div class="post-metadata">

**Author:** ![markstos](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/markstos/32/18182_2.png) [@markstos](https://forum.ghost.org/u/markstos)\
**Post date:** [September 22, 2023, 9:03pm UTC](https://forum.ghost.org/t/help-using-gmail-with-docker-ghost/41404/2 "2023-09-22T21:03:32Z")

</div>

In your Docker Compose file, did you try setting the “secure” option for Gmail to true?

Also check that:

- You are running your Docker container such that it has access to the host network or whatever else it needs to access the outside world.
- From the host, test you can make the SMTP connection directly to Gmail outside of Ghost. That will isolate whether the issue is with your networking or credentials or whether the issue is with your Ghost or Docker configuration.

See for example: [Connecting to smtp.gmail.com via command line - Stack Overflow](https://stackoverflow.com/questions/1516754/connecting-to-smtp-gmail-com-via-command-line)

---

<div class="post-metadata">

**Author:** ![markstos](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/markstos/32/18182_2.png) [@markstos](https://forum.ghost.org/u/markstos)\
**Post date:** [September 22, 2023, 9:05pm UTC](https://forum.ghost.org/t/help-using-gmail-with-docker-ghost/41404/3 "2023-09-22T21:05:28Z")

</div>

Also, check that your hoster isn’t blocking outgoing access to the SMTP port you are trying.

---

<div class="post-metadata">

**Author:** ![shaftspanner](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@shaftspanner](https://forum.ghost.org/u/shaftspanner)\
**Post date:** [September 25, 2023, 6:25am UTC](https://forum.ghost.org/t/help-using-gmail-with-docker-ghost/41404/4 "2023-09-25T06:25:01Z")

</div>

Thanks @markstos your advice was sound, and I was able to confirm that I could make SMTP connections from the host to gmail.

That got me looking for other sample docker-compose files that included gmail and I eventually found an article on [Marius Hosting](https://mariushosting.com/synology-install-ghost-blogging-using-mysql-as-database/) that had slightly different docker-compose settings - once the email lines in my own docker-compose were replaced, it worked straight away!

The new settings that allowed me to send emails via gmail are:

```auto
      mail__transport: SMTP
      mail __options__ service: SMTP
      mail__from: Your-own-gmail-address
      mail __options__ host: smtp.gmail.com
      mail __options__ port: 587
      mail __options__ auth__user: Your-own-gmail-address
      mail __options__ auth__pass: Your-own-app-password

```
