# How to set SMTP config to use localhost?

**URL:** https://meta.discourse.org/t/how-to-set-smtp-config-to-use-localhost/131464
**Category:** Support
**Created:** [October 20, 2019, 5:02am UTC](https://meta.discourse.org/t/how-to-set-smtp-config-to-use-localhost/131464 "2019-10-20T05:02:37Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![mreach](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@mreach](https://meta.discourse.org/u/mreach)
#### Post date: [October 20, 2019, 5:02am UTC](https://meta.discourse.org/t/how-to-set-smtp-config-to-use-localhost/131464/1 "2019-10-20T05:02:37Z")

</div>

I have `postfix` configured to work on the local docker host such that a test via `swaks --to destination@domain.tld --from admin@hostdomain.tld --server localhost -tls` delivers as expected. It uses port 25 and sends out the email with no problem at all.

So I’m lead to the question: how do I set up app.yml SMTP config settings appropriately to utilize localhost for mail delivery?

---

<div class="post-metadata">

### Author: ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)
#### Post date: [October 20, 2019, 6:25am UTC](https://meta.discourse.org/t/how-to-set-smtp-config-to-use-localhost/131464/2 "2019-10-20T06:25:10Z")

</div>

Set SMTP address to 127.0.0.1

---

<div class="post-metadata">

### Author: ![mreach](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@mreach](https://meta.discourse.org/u/mreach)
#### Post date: [October 20, 2019, 2:03pm UTC](https://meta.discourse.org/t/how-to-set-smtp-config-to-use-localhost/131464/3 "2019-10-20T14:03:23Z")

</div>

So to be clear, are you saying only the IP should be configured and the other fields commented out? Eg:

```plaintext
  DISCOURSE_SMTP_ADDRESS: 127.0.0.1
  #DISCOURSE_SMTP_PORT: 25
  #DISCOURSE_SMTP_USER_NAME: 
  #DISCOURSE_SMTP_PASSWORD:
  #DISCOURSE_SMTP_ENABLE_START_TLS: true # (optional, default true)

```

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [October 20, 2019, 2:08pm UTC](https://meta.discourse.org/t/how-to-set-smtp-config-to-use-localhost/131464/4 "2019-10-20T14:08:02Z")

</div>

If it’s on the same docker host but within a different docker container you need to specify the host IP.

127.0.0.1 won’t work as that’s the loopback address. Each container sees 127.0.0.1 as itself.

---

<div class="post-metadata">

### Author: ![mreach](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@mreach](https://meta.discourse.org/u/mreach)
#### Post date: [October 20, 2019, 2:18pm UTC](https://meta.discourse.org/t/how-to-set-smtp-config-to-use-localhost/131464/5 "2019-10-20T14:18:34Z")

</div>

This is not in a different docker container, but simply on the docker host itself.

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [October 20, 2019, 2:19pm UTC](https://meta.discourse.org/t/how-to-set-smtp-config-to-use-localhost/131464/6 "2019-10-20T14:19:29Z")

</div>

It’s still going to need the host IP then.

---

<div class="post-metadata">

### Author: ![mreach](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@mreach](https://meta.discourse.org/u/mreach)
#### Post date: [October 20, 2019, 2:24pm UTC](https://meta.discourse.org/t/how-to-set-smtp-config-to-use-localhost/131464/7 "2019-10-20T14:24:19Z")

</div>

So in such a case you need to use the public IP or is thre a special IP scheme that Docker uses? For example, within the host I see `docker0` with `172.17.0.1` and within the container (`./launcher enter app; apt-get install ifconfig`) `eth0` is `172.17.0.2`. I suspect I should use the host’s `172.17.0.1` w/in the discourse container, but I wouldn’t want it to change on me somehow and at some point.

---

<div class="post-metadata">

### Author: ![mreach](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@mreach](https://meta.discourse.org/u/mreach)
#### Post date: [October 20, 2019, 7:51pm UTC](https://meta.discourse.org/t/how-to-set-smtp-config-to-use-localhost/131464/8 "2019-10-20T19:51:03Z")

</div>

Just to document here, the following was sufficient (all other SMTP lines commented out) to deliver to the docker host’s smtp server if no auth is necessary:

```plaintext
  DISCOURSE_SMTP_ADDRESS: 172.17.0.1
  DISCOURSE_SMTP_PORT: 25

```

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [November 19, 2019, 7:53pm UTC](https://meta.discourse.org/t/how-to-set-smtp-config-to-use-localhost/131464/9 "2019-11-19T19:53:12Z")

</div>

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