# Cannot receive the mail from email server

**URL:** <https://meta.discourse.org/t/cannot-receive-the-mail-from-email-server/171119>\
**Category:** Self-hosting\
**Created:** [November 24, 2020, 5:39am UTC](https://meta.discourse.org/t/cannot-receive-the-mail-from-email-server/171119 "2020-11-24T05:39:17Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![chiehpower](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chiehpower/32/200361_2.png) [@chiehpower](https://meta.discourse.org/u/chiehpower)\
**Post date:** [November 24, 2020, 5:39am UTC](https://meta.discourse.org/t/cannot-receive-the-mail-from-email-server/171119/1 "2020-11-24T05:39:17Z")

</div>

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 [discourse/docs/INSTALL-cloud.md at main · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/master/docs/INSTALL-cloud.md) that here are my steps below.

```plaintext
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,

```plaintext
sudo ./discourse-doctor

```

## First experiment

When my app.yml was set

```plaintext
DISCOURSE_HOSTNAME : 'localhost'

```

And fill up these information

```plaintext
  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`.

```plaintext
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:

```plaintext
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

---

_[View the full topic](https://meta.discourse.org/t/cannot-receive-the-mail-from-email-server/171119)._
