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 include:forum.news4starstuffs.com ~all_ for the record name forum.news4starstuffs.com (news4starstuffs.com is an established site on an established host I have, and I put an A record on it to point forum.news4starstuffs.com to the IP address Digital Ocean gave me… news4starstuffs.com 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 (forum.news4starstuffs.com) through my mail server hosted on my shared hosting provider (mail.news4starstuffs.com), 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_ADDRESS: mail.news4starstuffs.com
  DISCOURSE_SMTP_PORT: 2525
  DISCOURSE_SMTP_USER_NAME: forum@news4starstuffs.com
  DISCOURSE_SMTP_PASSWORD: <password removed to protect the innocent>
  #DISCOURSE_SMTP_ENABLE_START_TLS: true          
  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 test-zzaj0@mail-tester.com. . . 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 ====================
DISCOURSE_HOSTNAME=forum.news4starstuffs.com
SMTP_ADDRESS=mail.news4starstuffs.com
DEVELOPER_EMAILS=REDACTED 
SMTP_PASSWORD=REDACTED 
SMTP_PORT=2525
SMTP_USER_NAME=forum@news4starstuffs.com
LETSENCRYPT_ACCOUNT_EMAIL=REDACTED 

==================== 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        0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp   app


Discourse container app is running


==================== PLUGINS ====================
          - git clone https://github.com/discourse/docker_manager.git

No non-official plugins detected.

See https://github.com/discourse/discourse/blob/master/lib/plugin/metadata.rb for the official list.

========================================
Discourse version at forum.news4starstuffs.com: 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 http://www.mail-tester.com/
Sending mail to REDACTED  . . 
Testing sending to test-zzaj0@mail-tester.com using forum@news4starstuffs.com:<passwd>@mail.news4starstuffs.com:2525.
SMTP server connection successful.
Sending to test-zzaj0@mail-tester.com. . . 
Sending mail failed.

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

But when I run from my digital ocean vm forum.news4starstuffs.com:

_swaks --to test-zzaj0@mail-tester.com --from forum@news4starstuffs.com --server mail.news4starstuffs.com --port 2525 --auth LOGIN --auth-user forum@news4starstuffs.com -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 noreply@forum.news4starstuffs.com. 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='forum@news4starstuffs.com'"

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 @news4starstuffs.com email addresses from my A2Hosting website & services that I don’t want to interfere with)?

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.

저도 같은 문제를 겪고 있습니다. swaks 도구는 정상적으로 작동하며 이메일도 수신됩니다. A2에서 VPS를 사용 중이고, 로그에는 Net::ReadTimeout 외에 다른 오류가 없습니다.

혹시 해결 방법을 아시는 분 계신가요?

방금 이 문제를 해결했습니다. 이메일 계정의 CPanel 설정 페이지에는 포트 465를 사용하라고 되어 있습니다. 하지만 Discourse로 연결할 때는 포트 587을 사용해야 했습니다. 587은 TLS와 STARTTLS와 함께 사용되는 더 새로운 포트라고 생각합니다.

또한 'launcher rebuild app’을 실행하는 것을 잊지 마세요. 'launcher restart app’을 실행하면 설정 변경 사항이 무시되었습니다.

이 게시물을 이메일이 작동하지 않는 새 설치 환경에서 5시간 동안 가능한 모든 문제 해결 게시물을 확인하기 전에 봤으면 좋았을 텐데. 덕분에 정신 나가는 일에서 구해줘. 세상에 널 위한 좋아요가 부족해 :heart: :heart: :heart: :heart: :heart:

그럼 정확히 어떻게 해서 작동하게 만든 건가요? 이 게시글의 구체적인 실행 방법에 대해 아직 조금 혼란스럽습니다.