Cannot receive the mail from email server

Dear all,

I knew this issue which is a known issue and quite easily to meet it. I have read and tried a lot of testings, but I already got stuck on “sending email” this step.

I was following this https://github.com/discourse/discourse/blob/master/docs/INSTALL-cloud.md that here are my steps below.

git clone https://github.com/discourse/discourse_docker.git /var/discourse
cd /var/discourse

Go to /samples/ to copy standalone.yml to /containers/app.yml

Please amend the information about your server.
Next,

sudo ./discourse-doctor

First experiment

When my app.yml was set

DISCOURSE_HOSTNAME : 'localhost'

And fill up these information

  DISCOURSE_SMTP_ADDRESS: XXX
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: XXX
  DISCOURSE_SMTP_PASSWORD: XXX
  DISCOURSE_SMTP_ENABLE_START_TLS: true   

The email server is also built on internal network.
In the beginning, it can work. The discourse can correctly send the register email and I can also access the admin like normal.

However, when I set the localhost of HOSTNAME, I cannot use the internal IP (e.g., 10.1.X.X) to access on browser.


Second experiment

So I only amended my DISCOURSE_HOSTNAME and I didn’t modify other information in app.yml.

DISCOURSE_HOSTNAME : '10.1.3.91'

PS 10.1.3.91 is my internal (local area) IP.

After I changed to this kind of hostname, I can access it on my browser. However, the email server cannot work anymore. I cannot receive the email from discoure.


Supplement

I tried to send the email via python with my SMTP.

The script is like below:

from email.mime.multipart import MIMEMultipart
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import smtplib

content = MIMEMultipart() 
content["subject"] = "Learn Code With Mike"  
content["from"] = " (my email) "  
content["to"] = " (testing email) "
content.attach(MIMEText("Demo python send email"))  


with smtplib.SMTP(host=" (as same as DISCOURSE_SMTP_ADDRESS) ", port="587") as smtp: 
    try:
        smtp.ehlo() 
        smtp.starttls()  
        smtp.login(" (as same as DISCOURSE_SMTP_USER_NAME) ", " (as same as DISCOURSE_SMTP_PASSWORD) ") 
        smtp.send_message(content)  
        print("Complete!")
    except Exception as e:
        print("Error message: ", e)

Then it can work well. Does it prove the email stmp information which is correct and be able to use?

Is there any idea about this issue?

For email server part, I have also tried the Elastic Email, Mailjet but still not work.

Conclusion:

If DISCOURSE_HOSTNAME is used localhost, email server can work.
If DISCOURSE_HOSTNAME is changed to internal IP (i.e., local area IP), email server cannot work.

Thank you so much!!!

Best regards,
Chieh

1 Like

Update:

I can receive the email in the beginning of “congratulations, you installed Discourse!” and “register Admin Account” with the specific internal IP when I access on other device. However, after these steps, it will get error that it cannot find the page. Why is it originally able to access by internal IP and after this setting, the original IP will be invalid?
So strange …

The problem seems be solved by myself.

go to /etc/hosts

and set the hostname being your IP.
hostname is also set IP.

DISCOURSE_HOSTNAME can use internal IP.
Then it can work.

(Of course, it is only for internal use.)

3 Likes

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