Cannot send mail with Discourse on new install but can from command line (on digital ocean)

I’ve just installed a new Ubuntu 18.04 droplet on Digital Ocean and installed Discourse manually through The Official Discourse Guide.

I cannot for the life of me figure out how to get mail working, so I cannot log in to the Admin account I’m creating (confirmation doesn’t go through). I’m new to banging my head against DNS records to get mail working and I added the TXT record _v=spf1 a ~all_ for the record name ( is an established site on an established host I have, and I put an A record on it to point to the IP address Digital Ocean gave me… is a shared hosting environment so I don’t have direct access to the mail logs on that server)… but I don’t think that this is the issue, because I can telnet (well, swaks) and send mail from my DigiOcean server ( through my mail server hosted on my shared hosting provider (, as I am trying to get Discourse to do, and it goes through fine.

Any suggestions would be much appreciated - here is some info to make my issue clearer:

my current containers/app.yml file:

  DISCOURSE_SMTP_PASSWORD: <password removed to protect the innocent>
  1. confirmation emails do not arrive at the inbox sent to
  2. When I run discourse-doctor it runs fine up to asking for an email to send to, then when I put one in it hangs for ~30 seconds, gets up to Sending to . . followed by “sending mail failed”

Here is the copy of the log file the good doctor gives a link to (passwd removed):

DISCOURSE DOCTOR Thu Nov 29 06:43:55 UTC 2018
OS: Linux News4StarStuffs 4.15.0-39-generic #42-Ubuntu SMP Tue Oct 23 15:48:01 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Found containers/app.yml

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

==================== DOCKER INFO ====================
DOCKER VERSION: Docker version 18.09.0, build 4d60db4

DOCKER PROCESSES (docker ps -a)

CONTAINER ID        IMAGE                 COMMAND             CREATED             STATUS              PORTS                                      NAMES
e6d4da2abe2b        local_discourse/app   "/sbin/boot"        4 minutes ago       Up 4 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 Discourse 2.2.0.beta4 
Discourse version at localhost: Discourse 2.2.0.beta4 

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

              total        used        free      shared  buff/cache   available
Mem:            985         655          61          22         267         169
Swap:          2047         338        1709

==================== DISK SPACE CHECK ====================
---------- OS Disk Space ----------
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        25G  8.3G   16G  35% /

---------- Container Disk Space ----------
Filesystem      Size  Used Avail Use% Mounted on
overlay          25G  8.3G   16G  35% /
/dev/vda1        25G  8.3G   16G  35% /shared
/dev/vda1        25G  8.3G   16G  35% /var/log

==================== DISK INFORMATION ====================
Disk /dev/vda: 25 GiB, 26843545600 bytes, 52428800 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
Disklabel type: gpt
Disk identifier: 4BE72FBF-27EC-46C1-AA51-D9AB03EFC2B6

Device      Start      End  Sectors  Size Type
/dev/vda1  227328 52428766 52201439 24.9G Linux filesystem
/dev/vda14   2048    10239     8192    4M BIOS boot
/dev/vda15  10240   227327   217088  106M Microsoft basic data

Partition table entries are not in disk order.

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

==================== MAIL TEST ====================
For a robust test, get an address from
Sending mail to REDACTED  . . 
Testing sending to using<passwd>
SMTP server connection successful.
Sending to . . 
Sending mail failed.

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

But when I run from my digital ocean vm

_swaks --to --from --server --port 2525 --auth LOGIN --auth-user -tls_

it goes through fine, right away:

Unless you change the reply to address at the bottom of the app.yml file, Discourse is sending as My guess is that Your mail server isn’t accepting that address in the from line.


thanks for the reply, Jay. I uncommented that custom command and set it to look like:

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

but no love. Same behaviour as before, connects to SMTP server, “sending mail . . .”, sending failed.

I came across this other post from someone using the same shared hosting provider as I am (A2Hosting) and they struggled at this same step for 3 weeks.

Any other ideas for what I can try? Or should I maybe look at using a third party SMTP service (Google, or try to find a reasonable rate from one of the paid options like Mailgun or Sparkpost) (assuming it’s possible or not incredibly difficult for an idiot to get it to work considering I’m already using email addresses from my A2Hosting website & services that I don’t want to interfere with)?

1 Like

Did you do a rebuild after? (destroy and restart won’t do it).

If only there were several recommended mail services that provide 10K free messages a month.


I did indeed rebuild with the discourse-setup program. Still the same issue. Alright I’ll try with one of those - was just hoping to get some advance warning as to possible issues I might run into that’ll lead to another road-block and heartache, since I’m going to be trying to send mail through a 3rd party mailserver for my Discourse forum from the same @ domain as my current webhost, website & other services are using my host’s A2Hosting mailserver for. Crossing my fingers and twiddling with DNS records and hacking away at mail servers is not my forte, and time is unfortunately a far too finite resource for me.

I’m having the same issue. The swaks tool works and I receive the email. I have a VPS on A2. No errors in the log other than Net::ReadTimeout.

Anyone got any pointers?

Just resolved this. The CPanel configuration page for the email account says to use port 465. However, when connecting with discourse I had to use port 587. I believe 587 is the newer port used with TLS and STARTTLS.

Also, be sure to run ‘launcher rebuild app’. Running ‘launcher restart app’ ignored the configuration changes.


I wish I’d seen this post before I spent 5 hours going through every possible troubleshooting post for not being able to get email working on a new install. You save me from driving myself crazy. There are not enough likes in the world for you :heart: :heart: :heart: :heart: :heart:

1 Like

so what did you do to make it work exactly? still a little confused on the actionable of this post