Gmail Email problem configuration

Hello, I have problem with mail configuration with ghost. I’m using docker image and configure the mail data with environment variables like this:

I used Gmail smtp for send mails in other systems with success, but without success on ghost :frowning:

This is my configuration:
- mail__transport=SMTP
- mail__options__host=smtp.gmail.com
- mail__options__port=587
- mail__options__auth__user=no-reply@gmailsubdomain.com
- mail__options__auth__password=password
- mail__from=no-reply@gmailsubdomain.com

Also I try with the secureConnection=true or false and with port 465 or 587. On all cases the error was:

Failed to send email. Reason: Invalid login - 535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/?p=BadCredentials e6sm1879051qkg.89 - gsmtp.

I use the above settings for gitlab on my own server and all works ok…
any help appreciated…

Same error for me (Failed to send email. Reason: Invalid login - 535 Authentication failed: Bad username / password.)
I’m using GHOST 2.37.0 On Azure App Service (Windows)
Config added to config.production.json
“mail”: {
“transport”: “SMTP”,
“from”: “‘my email’ av8or@email.com”,
“options”: {
“service”: “Gmail”,
“auth”: {
“user”: “av8or@gmail.com”,
“pass”: “P@ssowrd”
}
}
},
Set the gmail to “allow less secure”

perhaps the password is spelled wrong - owrd?

No, the password is ok. Also I tried to use the configuration with another software with smtp and It works ok, so the problem is with ghost or ghost in docker…

Any news on this one? I am also stuck here…

Is it a personal email account? If so, try changing to:

mail__options__auth__pass=password

I also had to generate a password for apps in Google. See here.

Working fine for me. Hope this helps.

I had some fun with this a while ago. I managed to get it working in the end with a custom domain in GSuite, not a Gmail account. But it should be very similar.

The config in your config.*.json file should look something like this.

"mail": {
    "from": "from_email_address",
    "transport": "SMTP",
    "options": {
        "service": "gmail",
        "host": "smtp.gmail.com",
        "port": 465,
        "auth": {
            "user": "email_address",
            "pass": "app_password"
        }
    }
},

In your Gmail or GSuite account, log into the account, go to My Account, Security, App Passwords. Create an app password (bypasses 2 Step Verification if it is setup) then try sending an email from Ghost.

Please note: When you send an email for the first time it may be blocked. Check for a blocked email in your Google account to “approve” Ghost sending the email. You should then be free to send any emails once you have approved it.

4 Likes

That solved it for me! Thx a lot!

Since I inject those setting into a docker compose container via a docker-compose.yaml, it looks this way here:

version: '3'
services:
    ghost:
        image: ghost:latest
        restart: always
        depends_on:
            - db
        environment:
            url: http://localhost
            database__client: mysql
            database__connection__host: db
            database__connection__user: root
            database__connection__password: your_database_root_password
            database__connection__database: ghost
            logging__path: /logs
            logging__info: 'info'
            mail__transport: 'SMTP'
            mail__from: 'email_address'
            mail__options__service: 'gmail'
            mail__options__host: 'smtp.gmail.com'
            mail__options__port: 465
            mail__options__secure: 'true'
            mail__options__auth__user: 'email_address'
            mail__options__auth__pass: 'app_password'
            volumes:
                - ./ghost_content:/var/lib/ghost/content
                - ./ghost_logs:/logs

Hello. So, I’m new to Ghost. Just recently got it set up using the DO OCA. It was working fine except email. I found this and edited my config.*.json file. I wasn’t thinking and I tried to restart Ghost from root. :man_facepalming: Obviously, it told me I could not do that, but it still executed. Now I’m getting a 502 error. Any help on fixing it?

Cheers.

Okay. After a little searching, the following on Github solved my problem with my 502. My email sending also works correctly now too! Thanks!

Thanks for the tip.

This is how I got it working on my self-hosted Ghost using a custom domain with SMTP going to Google. And bonus points, it uses a one-time password instead of dumping my credentials on a file somewhere for the hackerz to find. :stuck_out_tongue:

I tried with the TLS settings and secure: true but ended up getting OpenSSL version errors.


Randy