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