Troubleshooting email on a new Discourse install

You can use any email address as admin account as long as it is a valid email address able to receive emails.

On mailgun SMTP, use port 2525 instead of 587 and you should be good to go.

1 Like

What are the correct settings passed to ./discourse-setup for connecting to an smtp server on localhost:25 without auth?

I’m very surprised that this isn’t supported OOTB; it’s the default config on most linux installs…

My server runs postfix locally; it is not accessible from the Internet. It works fine, for example, when running the mail command. I found a few unofficial guides on the Internet suggesting changes to /var/discourse/containers/app.yml, and I finally got it to install & start with the following settings:


Note that if I omit the DISCOURSE_SMTP_USER_NAME or DISCOURSE_SMTP_PASSWORD variables, your install script yells at me stating that they’re required (bug?).

And now when I click the “Resend Activation Email” button in the Discourse wui, this entry pops-up in the log file (/var/discourse/shared/standalone/log/rails/production.log):

Started PUT "/finish-installation/resend-email" for at 2019-11-07 13:15:31 +0000
Processing by FinishInstallationController#resend_email as HTML
  Parameters: {"authenticity_token"=>"SzQCvRWiqdXsBKzOjIB0X7KkvXro7Od6SdP8Qa8vvrskPeNYZNos5ORHJfyDUrHiKShZR/txM6NHuqHHCQCR1w=="}
  Rendering finish_installation/resend_email.html.erb within layouts/finish_installation
  Rendered finish_installation/resend_email.html.erb within layouts/finish_installation (Duration: 0.7ms | Allocations: 103)
  Rendered layouts/_head.html.erb (Duration: 0.5ms | Allocations: 103)
Completed 200 OK in 98ms (Views: 3.0ms | ActiveRecord: 0.0ms | Allocations: 4763)
  Rendering layouts/email_template.html.erb
  Rendered layouts/email_template.html.erb (Duration: 0.5ms | Allocations: 141)
Delivered mail (11.3ms)
Job exception: wrong authentication type none

…But my authentication type is ‘none’. What should the correct setting be for no authentication?

EDIT: also, can someone link me to the doc that defines all of the possible “DISCOURSE_SMTP_*” variables and all of their valid values?

EDIT2: this is proving to be far more difficult than it should be. I think ‘localhost’ is resolving inside the docker container to the Discourse docker container itself (app) – not the docker host that is running my postfix smtp server. That’s further complicated by postfix’s mynetworks and iptables (which were configured by the discourse-setup script or its children scripts). What’s the correct config here to just have Discourse use the smtp server on which I want to run Discourse, with no smtp auth?

I think that hasn’t been very true for about 20 years.

You can’t use discourse-setup for situations like yours because few people have non password protected smtp servers, even behind a firewall.

What I would do is configure smtp passwords for my mail server. There really isn’t much downside.

If you don’t want to do that I think that instead of “none” for authentication you might want “” (and similarly for the password and username).

I think so too. You might try using the container name. I think that you need to see that they are both on the same docker network.


In 2019, it’s the default config for postfix on RHEL/CentOS. Postfix binds only to the loopback interface and drops all smtp requests that don’t originate from No auth required. I’m not sure about debian, but I’d imagine exim has a similar default config.

A couple relevant topics on these forums from other users who hit this issue:

There doesn’t appear to be a topic for how to set this up on RHEL/Cent OS with the necessary changes to both Discourse and postfix, so I’m documenting this here.

This does not appear to be possible with the discourse-setup script, but I did get this to work.

First, I had to figure out the IP address of the docker host as the docker container sees it. Using won’t work because the docker container will see as itself. Rather, we need to specify the IP address or hostname of the docker host that is running the postfix SMTP server, and one that is addressible by the docker container (so not your docker host’s Internet-facing IP address if you want your SMTP server to not be Internet-accessible, for example).

I extracted the relevant IP address of the docker host ( from the docker0 interface by executing this on the docker host:

[maltfield@osestaging1 ~]$ ip address show docker0
3: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP 
    link/ether 02:42:80:35:65:a1 brd ff:ff:ff:ff:ff:ff
    inet brd scope global docker0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:80ff:fe35:65a1/64 scope link 
       valid_lft forever preferred_lft forever
[maltfield@osestaging1 ~]$

Then I edited my Discourse app’s yaml file, setting the “DISCOURSE_SMTP_ADDRESS” to from above.

[maltfield@osestaging1 ~]$ cd /var/discourse/
[maltfield@osestaging1 discourse]$ grep SMTP containers/app.yml
[maltfield@osestaging1 discourse]$ 

Note that I first tried to use the internal docker hostname host.docker.internal for this, but apparently this hostname isn’t available to linux docker users

Because the default postfix configuration in RHEL/Cent OS binds only to (which is good), you’ll need to change /etc/postfix/ so it also binds to the docker0 interface and add that subnet to the mynetworks group so that SMTP traffic coming from docker containers will be accepted by postfix.

[maltfield@osestaging1 postfix]$ grep -ir '172.17' /etc/postfix/*
/etc/postfix/ =,
/etc/postfix/ =,
[maltfield@osestaging1 postfix]$ 

After those changes, rebuild Discourse and it should now be able to send emails out through your docker host’s postfix.

/var/discourse/launcher rebuild app

While this works, I have a few questions:

  1. Is there some other environment variable or hostname that already points to the docker host ( in this case)?

I noticed that there is a DISCOURSE_HOST_IP environment variable “injected” by launcher. Is it possible to set this DISCOURSE_SMTP_ADDRESS yaml key to the same value as the other’s yaml key with something like this?

  1. In general, how durable is the IP of the docker host? Is it always this IP on RHEL/Cent OS systems? Will it ever change on me?

Hi all,

So, I’m running into a brick wall with the final email configuration, and I’m hoping someone can point me in the right direction.
Here are the discourse-doctor logs:

DISCOURSE DOCTOR Sat Nov 30 14:46:40 UTC 2019
OS: Linux ip-172-31-83-113.ec2.internal 3.10.0-1062.4.3.el7.x86_64 #1 SMP Wed Nov 13 23:58:53 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Found containers/app.yml

==================== YML SETTINGS ====================

==================== DOCKER INFO ====================
DOCKER VERSION: Docker version 19.03.5, build 633a0ea

DOCKER PROCESSES (docker ps -a)

CONTAINER ID        IMAGE                 COMMAND             CREATED             STATUS              PORTS                                      NAMES
25b9f765fadc        local_discourse/app   "/sbin/boot"        20 minutes ago      Up 20 minutes>80/tcp,>443/tcp   app

Discourse container app is running

==================== PLUGINS ====================
          - git clone

No non-official plugins detected.

See for the official list.

Discourse version at NOT FOUND
Discourse version at localhost: NOT FOUND

==================== MEMORY INFORMATION ====================
OS: Linux
RAM (MB): 1880

              total        used        free      shared  buff/cache   available
Mem:           1836        1026          91          26         718         600
Swap:          2047          32        2015

==================== DISK SPACE CHECK ====================
---------- OS Disk Space ----------
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda1       20G   13G  7.7G  62% /

==================== DISK INFORMATION ====================

Disk /dev/xvda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000b956b

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *        2048    41943006    20970479+  83  Linux

==================== END DISK INFORMATION ====================

==================== MAIL TEST ====================
For a robust test, get an address from
Sending mail to REDACTED  . .
Testing sending to using
======================================== ERROR ========================================
                                    UNEXPECTED ERROR


====================================== SOLUTION =======================================
This is not a common error. No recommended solution exists!

Please report the exact error message above to
(And a solution, if you find one!)

==================== DONE! ==================== 

And here is, what I think, is tripping me up when I tail the prod.log

Delivered mail (60119.5ms)

Now, I went into containers/app.yml and uncommented out the default email to make it:

- exec: rails r "SiteSetting.notification_email=''"

I did rebuild the app after I saved that setting -
./launcher rebuild app

I’m running out of AWS with AWS’ Workmail set up. I can connect to telnet w/o issue, so I don’t think I’m being blocked.

Any assistance or direction would be appreciated!

I think

should look like

or was the message changed once and Delivered mail is the same then Send mail to?

You may have the same problem as described by @jehrlich.
I’ve got stuck at the same point, based on the description

Is the email domain correct?

I tested the from-address used by discourse via and got

"Relaying disallowed as noreply@…

what led me to SMTP - Simple Mail Transfer Protocol Configuration in Zoho Mail, and What is the difference between the “From” and “Sender”? – Mailgun Help Center what it turn ended in the conclusion that I need to change notification email what can be any email address accepted by your email relaying service, as described in Can domain name of discourse hosting and sending emails be different?.
I’m only wondering why I shall do

as far as I understand, email notification always sent using the email address specified in SiteSetting.notification_email=.
It is nowhere mentioned that discourse is going to use the address specified in DISCOURSE_SMTP_USER_NAME:.
@pfaffman or anyone else here around who can enlighten us?

Thank you all so much for all your responses. I will give them a try when I’m able to hop back on the server. Much appreciated!

1 Like

After a new Discourse installed refrenced from github install tutorial, then register administrator of discoure, but the email is not working. The command telnet 465 is working fine. mail-tester website can also recieved the email from my smtp user account. What’s the issue here?

======================================== ERROR ========================================

end of file reached

====================================== SOLUTION =======================================
This is not a common error. No recommended solution exists!

Please report the exact error message above to
(And a solution, if you find one!)

It looks like there is an issue with discourse-docker. If mail-tester is receiving mail then mail is working. Why are you using discourse-doctor?

I fully with you that all happens on a voluntary base as long as you don’t pay for it. It has been like this and will be. I’m doing my best contributing where I can.
Involving Jay was due to my quote of a very specific statement of him.
We all learning every day another thing, so I’ve just figured that it was once the same for him What's the different between rebuild and bootstrap.
I tried once to understand it in more detail too and it is still on my agenda, The launcher command in the /var/discourse folder are not self-explaining.
I lost on focus on this as the folks I’m doing all this on a purely voluntary base hadn’t been sure yet if discourse is the right platform for them. It has changed recently, what put me back on this track.
So I’m caught in the same situation to help others to make the vision prospering, without asking for any compensation than a thank you.
I have only the personal demand to explain and document things I do and for that purpose, I need to understand some settings in more detail than the standard first installer as the may can life with occasional downtime or running only with the default settings.
I’m trying to spread to my findings as good as possible here but if I lack understanding, I cannot explain as good as I wish to do.

I’m helping the folks from to run their own hosted community platform to allow them to leave their paid Mighty Networks platform, what rises fees significantly for next year and slack.
The wish is to replace it by mattermost and discourse where I’m currently the only system administrator trying to get it run (and keeping their budget untouched to spend it on the platform and all related).
As the platform is very important I have to run the community platform on decoupled from their platform (for the time being) what comes with limitations, what causes me to deviate from the recommendations laid out in the email guide.

All that I would like to know is if the email sent by SiteSetting.notification_email is the address is the only one to send any kind of notification, using the login credentials given by

SMTP server address? []: 
SMTP port? [587]: 
SMTP user name? []: 
SMTP password? [pa$word]: 

If so, I don’t agree that the line

After getting the first signup email, re-comment the line. It only needs to run once.

as it indicates that email given there is used only once, so notifications are sent using an email address as described by

The default email from address is based on the install domain plus subdomain, so if your URL is it will be:
what will cause the same issue again.

If this is not the case, the line may not be re-commented as, for whatever reason, I have to run ./launcher rebuild app, what will apply all settings given in app.yml what ends me up in the same issue over again.

I hope that I can specify the email address used for sending notifications by setting SiteSetting.notification_email and hoping that discourse will tell the sender alias as specified in RFC 2822 Internet Message Format , using SMTP user name and SMTP password?.

I tested the smtp services by using and will do telnet as described e.g. by

to ensure that not the hosting service or host is blocking sending emails.

Last but not least I would be happy to know which one of Delivered mail or Sent mail is the right output in tail shared/standalone/log/rails/production.log to confirm that the email is sent and what is the difference, respectively. Currently, both outputs make me thing, that discourse thinks that the email was sent.

I going to publish all my actions here to make life easier for others

This was blocked until I made the device have a fully qualified domain name (FQDN)

Edit: issues is solved, turned out discourse doctor gave an error while everything was fine.

hello, I hope someone can help me because I’m breaking my head over this and can’t figure out what is wrong.

I have setup the forum successfully, however it doesn’t send mails. For example, mail to reset password. I tried a test mail from the mail test in admin CP and it didn’t arrive.

error: There was a problem sending the test email. Please double-check your mail settings, verify that your host is not blocking mail connections, and try again.

I did all the steps in the troubleshooting first.

i checked the logs and email is getting sent but refused:

Connection refused - connect(2) for “[domainname]" port 587

I have setup the email account at discourse@[domainname], also added a noreply@[domainname].

here are the settings in app.yml.

DISCOURSE_SMTP_USER_NAME: discourse@[domainname]

what do I need to change/where?

thank you so very much in advance!

  # WARNING the char '#' in SMTP password can cause problems!
  DISCOURSE_SMTP_ENABLE_START_TLS: true           # (optional, default true)

##- exec: rails r "SiteSetting.notification_email... change to - exec: rails r "SiteSetting.notification_email... (remove the ##)

  - exec: echo "Beginning of custom commands"
  ## If you want to set the 'From' email address for your first registration, uncomment and change:
  ## After getting the first signup email, re-comment the line. It only needs to run once.
  - exec: rails r "SiteSetting.notification_email=''"
  - exec: echo "End of custom commands"

I solved the email problem through the above method, I hope this method can help other people.


so registration email was send as shown in the guide discourse/ at master · discourse/discourse · GitHub?
So the setup should be correct.

Have you tried to send an email doing telnet/openssl as described in Troubleshooting email on a new Discourse install

Thank you for your reply! The issue has been solved (sorry I forgot to post here, it’s in another topic) it turned out everything worked ok, but bc I used discourse doctor from the shell to check the settings (I was changing app.yml every time) - it turned out discourse doctor gave a sign something was wrong with mail while in fact it worked…


you are welcome. I’m dropping by here frequently; quite often as a last resort :grin:.
Quick answers keeping me motivated.

where? I could be helpful in future cases.

1 Like

Fair enough, I was too lazy to look it up when I posted.

Here it is: Discourse-doctor Error 503 AUTH command used when not advertised - but email works fine from admin CP

1 Like

To anyone trying to set up Discourse with an email from their shared hosting service, even if you’re instructed to use port 465, you need to use port 587 when setting up Discourse.

This is from my cPanel
No matter what I tried, I could not get Discourse to send me the initial registration email. Then I found this post that saved my life, used port 587, and suddenly everything worked, even though it is impossible for me to send mail from port 587.

So if you’ve set up Discourse to use port 465 and can’t get the email to send, skip all the telnet, discourse-doctor, production.log, etc. stuff and just try it with port 587 and see if that fixes it.


I was also amazed at what port worked for me, it was 2525…

Here is a link to a very good explanation of ports used for SMTP.

I also added that link to the 1st post of this topic.

is this something I have to handle with my mail-server?
sorry, I’m such a newbie trying to run my discourse, please give me some advice.