TryGhost / Ghost

Independent technology for modern publishing, memberships, subscriptions and newsletters.
https://ghost.org
MIT License
47.67k stars 10.41k forks source link

Cannot get ghost to send mail from Google Cloud Platform #6969

Closed tonyeung closed 8 years ago

tonyeung commented 8 years ago

Welcome to Ghost's GitHub repo! πŸ‘‹πŸŽ‰

Do you need help or have a question? Please come chat in Slack: https://ghost.org/slack πŸ‘«. See https://github.com/TryGhost/Ghost/issues/6968 for why I'm not asking in slack.

Issue Summary

Tested sending email using SMTP from ssh and verified that I can relay to mailgun using postfix and got test email. Mailgun also shows the mail on the log.

However, when sending a test notification from the lab tab, sometimes the button spins and nothing happens or a toastr with [object object] shows up.

confirmed in mailgun logs that nothing was submitted.

Steps to Reproduce

  1. Installed ghost from bitnami to google cloud platform.
  2. signed up for mailgun and then followed google's guide to setup postfix and was able to test send an email from ssh.
  3. Modified the ghost config to send using localhost so postfix will relay to mailgun, restart ghost
  4. Go to lab tab and send a test email

Any other info e.g. Why do you consider this to be a bug? What did you expect to happen instead?

Technical details:

    production: {
        url: 'http://104.197.36.249:80',
        mail: {
            transport: 'SMTP',
            options: {
                port: 2525,
                host: 'localhost',
            }
        },
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost.db')
            },
            debug: false
        },
        server: {
            host: '127.0.0.1',
            port: '2368'
        }
    },

also tried

    production: {
        url: 'http://104.197.36.249:80',
        mail: {
            transport: 'SMTP',
            options: {
                service: 'Mailgun',
                port: 2525,
                auth: {
                    user: 'mailgunusername',
                    pass: 'guid',
                },
            }
        },
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost.db')
            },
            debug: false
        },
        server: {
            host: '127.0.0.1',
            port: '2368'
        }
    },
tonyeung commented 8 years ago

I realize this isn't much information to go off of, I'd troubleshoot it myself but I'm not sure where the logs are, if any. I tried googling for ghost blog logs and while I've found that prd has less logs than dev, it didn't say where the logs are recorded to.

ErisDS commented 8 years ago

See #6968 for why I'm not asking in slack.

Please see the reply on that issue for what to do! This is our bug tracker, it's not for getting support with custom installations πŸ˜‰

Ghost's mail config is passed straight through to nodemailer 0.7.

tonyeung commented 8 years ago

@ErisDS Okay. Can you tell me how you guys troubleshoot emails in production when there is a bug? If I'm reading the nodemailer docs you linked correctly, it logs errors into the console rather than to disk. The current version allows me to attach a bunyan logger, but looking at the nodemail repo for version 0.7, the property doesn't exist on the options object.

mikeofireland commented 8 years ago

"Google Compute Engine does not allow outbound connections on ports 25, 465, and 587. By default, these outbound SMTP ports are blocked because of the large amount of abuse these ports are susceptible to." - https://cloud.google.com/compute/docs/tutorials/sending-mail/

I hit this when troubleshooting. Putting it just for reference.

zhaoyibo commented 7 years ago

As you may know, Google Cloud Platform doesn't allow outbound connection to ports 25, 465 and 587

So you just change port of MailGun to 2525

  "mail": {
    "transport": "SMTP",
    "options": {
        "service": "Mailgun",
        "port": 2525,
        "auth": {
            "user": "yourname",
            "pass": "yourpasswd"
        }
    }
  },

It works for me.

ernests commented 7 years ago

I encountered the same problem while setting up Ghost on Google cloud platform. Tried Sparkpost, Zoho and also Mailgun with not success. Changing port from 587 to 2525 saved the day. This should be mentioned in documentation.

ErisDS commented 7 years ago

Our documentation has a "suggest edits" button - I don't have enough context to know what to change or where 😊

ernests commented 7 years ago

Yes, I clicked it! It required me to register. As I have spent already way too much time on this, I didn't register. Left it here so hopefully, people can find it through google.

BirkhoffLee commented 6 years ago

@ernests It took me two days to figure out. You could have saved people's time by editing the documentation.

ernests commented 6 years ago

Oh wow! This is still a thing :) @BirkhoffLee thank you for editing

BirkhoffLee commented 6 years ago

@ErisDS I've made a edit on docs be sure to check

lunaticmonk commented 6 years ago

@vernak2539 I have also setup my Ghost Blog on GCP and it is working fine. If you are using the free mailgun sandbox, you will have to add your own email on mailgun and get it verified so as to send the emails.

vernak2539 commented 6 years ago

Sorry for the huge post, it was a long day yesterday and I didn't realise I duplicated the mail object in my config. It all works now after using the mailgun docs on google and having 1 mail object in my config

samsonlarsson commented 6 years ago

Okay, so I was dealing with this today, and nothing would work till I added the host value, as below.

"mail": {
    "transport": "SMTP",
    "options": {
        "service": "Mailgun",
        "host": "smtp.mailgun.org",
        "port": 2525,
        "auth": {
            "user": "yourname",
            "pass": "passcode"
        }
    }
},

Just for anyone else who might be experiencing this.