How to set SMTP config to use localhost?

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?

Set SMTP address to 127.0.0.1

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

  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)

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.

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

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

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.

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:

  DISCOURSE_SMTP_ADDRESS: 172.17.0.1
  DISCOURSE_SMTP_PORT: 25
1 Like

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