SMTP Server Isn't Found In Discourse

I have installed Discourse successfully on Free Oracle Cloud. Currently, I am in the finalized step where I need to verify the email address that I used during installation process.

I want to use my cPanel email that I created to send emails through Discourse app. I ran

./discourse-doctor

and the error was

======================================== ERROR ========================================
                                  SMTP SERVER NOT FOUND

getaddrinfo: Name or service not known

====================================== SOLUTION =======================================
The most likely problem is that the host name of your SMTP server is incorrect.
Check it and try again.

I ensured SMTP server credentials, which all were correct.

Does this type of email from cPanel supports sending emails through Discourse?

Free Oracle cloud blocks outgoing traffic for SMTP.

Many thanks @eris for your response. Any recommendation to use email for Discourse?

Also, on the other hand, I added this code below to etc/nginx/ngnix.conf to create proxy server in order to install Discourse.

discourse.stpl

server {
    listen      %ip%:%proxy_ssl_port% ssl http2;
    server_name %domain_idn% %alias_idn%;
    ssl_certificate      %ssl_pem%;
    ssl_certificate_key  %ssl_key%;
    error_log  /var/log/%web_system%/domains/%domain%.error.log error;

    location / {
        proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock:;
        proxy_set_header Host $http_host;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
    }

    location /error/ {
        alias   %home%/%user%/web/%domain%/document_errors/;
    }

    location @fallback {
        proxy_pass      https://%ip%:%web_ssl_port%;
    }

    location ~ /\.ht    {return 404;}
    location ~ /\.svn/  {return 404;}
    location ~ /\.git/  {return 404;}
    location ~ /\.hg/   {return 404;}
    location ~ /\.bzr/  {return 404;}

    include %home%/%user%/conf/web/%domain%/nginx.ssl.conf_*;
}

discourse.tlp

server {
    listen      %ip%:%proxy_port%;
    server_name %domain_idn% %alias_idn%;

    include %home%/%user%/conf/web/%domain%/nginx.forcessl.conf*;        

    location / {
        proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock:;
        proxy_set_header Host $http_host;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
    }

    location /error/ {
        alias   %home%/%user%/web/%domain%/document_errors/;
    }

    location @fallback {
        proxy_pass      http://%ip%:%web_port%;
    }

    location ~ /\.ht    {return 404;}
    location ~ /\.svn/  {return 404;}
    location ~ /\.git/  {return 404;}
    location ~ /\.hg/   {return 404;}
    location ~ /\.bzr/  {return 404;}

    include %home%/%user%/conf/web/%domain%/nginx.conf_*;
}

Now, after I installed the discourse successfully, do I need to delete them or keep them?

Appreciate your response.

You need to keep the template forever…

You might be able to connect to relay over a different port an connect to Amazon SES or SMTP2GO.

But never used Discourse for admin side…

1 Like

Appreciate your response. I’ll keep them, however each time I restart the service a window error pops up saying ‘can’t restart nginx’. Is that notification normal?

If you have error run:

nginx -t

And see if there is any config error

Yes, just ran the command and here is the output:

nginx: [emerg] "server" directive is not allowed here in /etc/nginx/nginx.conf:168
nginx: configuration file /etc/nginx/nginx.conf test failed

What could it imply?

Check: /etc/nginx/nginx.conf line 168 There is server and it it is not allowed…

Yes, I made changes on it. Now there is another error:

nginx: [emerg] invalid port in "%ip%:%web_ssl_port%" of the "listen" directive in /etc/nginx/nginx.conf:165
nginx: configuration file /etc/nginx/nginx.conf test failed

Same as before if you added certain template code in nginx.conf you should remove it…

As it is an nginx issue and not an Hestia issue I can’t help with it…

1 Like

Many thanks @eris. Properly an update is need from nginx’s side to solve this issue…

Hi Eris

Just bought a professional email package from networksloution.com and I put the credentials and port number of SMTP correctly in app.yml. Still when I issue this commend:

./launcher rebuild app

it throws the same error, which is SMTP NOT Found? I made thousands of check for the information I put in the app. Do you mean Oracal block outgoing traffic for SMTP even if the port is different? They want me to upgrade the account, right?

Oracle blocks outgoing traffic on port 25, use 587 or 465.

Many thanks @Raphael. I’ve followed your advice and used the port 587 as it’s set by email provider I bought pro email from. Here are the settings from the app.yml with of course changing the actual credentials.

  ## Required. Discourse will not work with a bare IP number.
  DISCOURSE_HOSTNAME: talk.tiptopcomputers.shop  # I am using subdomain for Discourse.

  ## TODO: List of comma delimited emails that will be made admin and developer
  ## on initial signup example '[email protected],[email protected]'
  DISCOURSE_DEVELOPER_EMAILS: '[email protected]'

  ## TODO: The SMTP mail server used to validate new accounts and send notifications
  # SMTP ADDRESS, username, and password are required
  # WARNING the char '#' in SMTP password can cause problems!
  DISCOURSE_SMTP_ADDRESS: smtp.XXXXXXXXXXXX  
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: [email protected]
  DISCOURSE_SMTP_PASSWORD: "6372hudshas65"   # Fake Password just for example 
  #DISCOURSE_SMTP_ENABLE_START_TLS: true           # (optional, default true)
  DISCOURSE_SMTP_DOMAIN: tiptopcomputers.shop
  DISCOURSE_NOTIFICATION_EMAIL: [email protected]

  ## If you added the Lets Encrypt template, uncomment below to get a free SSL certificate
  LETSENCRYPT_ACCOUNT_EMAIL: [email protected]

I can tell you that I double check the credentials many times, but no luck. The error is:


======================================== ERROR ========================================
                                  SMTP SERVER NOT FOUND

getaddrinfo: Name or service not known

====================================== SOLUTION =======================================
The most likely problem is that the host name of your SMTP server is incorrect.
Check it and try again.
=======================================================================================

I followed the Email troubleshooting guide published by the discourse team, but still the error persists. for some reason, I suspect if the email domain is incorrect since the host name is subdomain whereas the email domain contains root domain, so I ran the commend below after uncomment it and changed the value to the actual email for one time:

#- exec: rails r "SiteSetting.notification_email='[email protected]'"

Then rebuild the app

./launcher rebuild app

The error drives me crazy because I clearly followed the instruction, nothing happens as expected! However, I have a doubt if the error comes from the discrepancy between the host name and the email domain. Does discourse require email domain that is similar to root domain? Am I missing something in my work? Thank you for your time…

Update: I finally managed to fully install Discourse it was the DNS records that weren’t inputted
properly.

Thanks for reading…

For hestia we use the following configuration:

  ## TODO: List of comma delimited emails that will be made admin and developer
  ## on initial signup example '[email protected],[email protected]'
  DISCOURSE_DEVELOPER_EMAILS: '[email protected]'

  ## TODO: The SMTP mail server used to validate new accounts and send notifications
  # SMTP ADDRESS, username, and password are required
  # WARNING the char '#' in SMTP password can cause problems!
  DISCOURSE_SMTP_ADDRESS: mail.hestiacp.com
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: [email protected]
  DISCOURSE_SMTP_PASSWORD: PutPasswordHere
  DISCOURSE_SMTP_AUTHENTICATION: login
  DISCOURSE_SMTP_ENABLE_START_TLS: true
  DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: none

Which is working properly, more I can’t help - maybe you’ll find more help at the discourse support forum.

Many thanks @Raphael I managed to solve it by changing the SMTP server address to XXXX.com, no prefix is needed from my end.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.