Troubleshoot email on a new Discourse install

You just installed Discourse via the install guide, but email doesn’t seem to work. Unfortunately this means you can’t log in as an admin to finalize the install. :cry: Let’s troubleshootize!

Try the doctor :woman_health_worker:

If you run ./discourse-doctor it will check several ways that your mail configuration might be broken, and offer advice. Try that first.

Did you enter email settings correctly?

The simplest way is to run ./discourse-setup again. Did you enter everything correctly? But wait! If your password has anything other than numbers and letters, you might be better off editing your app.yml with nano or your favorite editor.

You can also double check the settings in your containers/app.yml file. A valid email section looks like this:

DISCOURSE_DEVELOPER_EMAILS: 'name@example.com'
DISCOURSE_SMTP_ADDRESS: smtp.mailgun.org
DISCOURSE_SMTP_PORT: 587
DISCOURSE_SMTP_USER_NAME: postmaster@discourse.example.com
DISCOURSE_SMTP_PASSWORD: aUd34cdWKCu6CTjfoH7ykk

Closely examine all values for correctness. Note that:

  • it all aligns
  • no leading # characters
  • single quotes around the developer email field
  • password does not include #, ", ', %, ] or other special characters (a # in a YAML value can be misinterpreted as a comment; if you must use special characters, wrap the value in double quotes, e.g. DISCOURSE_SMTP_PASSWORD: "#pass#ord")

If you had any errors in your app.yml and made changes, you MUST rebuild the container for those changes to take effect!

cd /var/discourse/
./launcher rebuild app

Well, you don’t always need to rebuild

Doing a rebuild will often fix things that seem broken, but it takes a while. There are times when a full rebuild is not necessary; the above is usually the best advice, but If you change just SMTP settings, you can do just this to apply them without doing a full rebuild:

cd /var/discourse
./launcher destroy app
./launcher start app

Are your SMTP connections being blocked?

To confirm that your server can indeed contact the email server, issue this command:

telnet smtp.mailgun.org 587

If you can’t connect this way, you’re almost certainly blocked. (And if you do get connected, the escape character for SMTP is ctrl+], then use quit to exit telnet.)

If this happens, first try port 2525, and if that fails, contact your cloud provider support and confirm that your email connections are not being blocked.

What do the Discourse logs say?

From the command line, issue this command:

cd /var/discourse
tail shared/standalone/log/rails/production.log

This will show the last few lines of the log. Look for anything mail related. If you need to view the fuller logs, try

less shared/standalone/log/rails/production.log

To page through the complete log, press space or type GG to jump to the end. Look closely for any email related messages or press /, type email, and hit enter to search.

What do your email provider logs say?

Assuming there are no errors in the Discourse logs, or your Discourse mail configuration, the emails probably went out. The question, is what did your email provider do with them?

Most email providers have a log viewing function. Check the logs for your email domain and see what happened with the incoming emails.

Did you properly set up DKIM and SPF records for your domain?

You must enter those crucial DNS records for DKIM and SPF, otherwise your emails may arrive only sporadically, if at all.

Is the email domain correct?

The default email from address is based on the install domain plus subdomain, so if your URL is discourse.example.com it will be:

noreply@discourse.example.com

But if your mail provider is expecting:

noreply@example.com

.. you may have problems! To get around this, edit and uncomment this exec line in app.yml

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

You’ll need to issue a rebuild after uncommenting the above line and setting the from email address as required.

You can also change this from the command line, if needed:

./launcher enter app
rails r "SiteSetting.notification_email = 'discourse@yoursite.com'"
exit

If using Mailgun – have you activated your domain and provided credit card info?

If you are using Mailgun, after you enter your DKIM and SPF records, you must visit https://mailgun.com/app/domains/YOUR.DISCOURSE.DOMAIN.com and click the “Check DNS Records Now” button. At the top of that page you should see “State ACTIVE” (in a calming green). If it says “State Unverified” (in a scary warning-yellow) Mailgun will not accept mail.

Mailgun now requires a credit card in order to deliver mail (other than to you). If your mailgun logs have a message about “free accounts,” this is your problem.

Other mail services have similar requirements.

Are you using an IP address as the mail domain?

This does not work in our experience. You must use a domain name when sending email, not an IP address like 192.168.1.1.

If you really want to go on with an IP address, try mail settings similar to these:

DISCOURSE_SMTP_ADDRESS: 172.17.0.1         # e.g. use internal docker IP here
DISCOURSE_SMTP_PORT: 587
DISCOURSE_SMTP_USER_NAME: "YOUR-SMTP-USER-NAME"
DISCOURSE_SMTP_PASSWORD: "YOUR-SMTP-PASSWORD"
DISCOURSE_SMTP_ENABLE_START_TLS: true     # (optional, default true)
DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: none
DISCOURSE_SMTP_DOMAIN: example.com

Need to log in without receiving a registration email?

We don’t recommend this, because your email is still broken, and you have a broken Discourse until email is working. But if you absolutely must log in as admin with email broken, here’s what to do:

cd /var/discourse
./launcher enter app
rake admin:create

And answer the prompts. It takes a few seconds before they appear. When it asks for the password, you will not be able to see what you type. That is why it makes you type it twice.

Email smtp port selection (Using 465?)

The ability to be able to AUTH using ‘telnet’ is extremely important in your first steps of email troubleshooting.

Port 465 (SMTP over SSL) uses implicit TLS. If you need to use port 465, add this to your app.yml:

DISCOURSE_SMTP_PORT: 465
DISCOURSE_SMTP_FORCE_TLS: true

You may also need to try alternate ports such as port 2525 or port 587 (Mail Submission) when things do not seem to work as expected.

Command Line SMTP tests for experienced sysadmins

If you’re comfortable with the command line, these might help diagnose network or certificate problems. If these do not seem “easy-to-follow” then you should please ignore this section.

See also Test SMTP authentication and StartTLS - Sysadmins of the North.

Office 365 Tweaks

If you’re using Office 365, be sure to include these (the first line is what you are likely missing):

DISCOURSE_SMTP_AUTHENTICATION: login
DISCOURSE_SMTP_ENABLE_START_TLS: true
DISCOURSE_SMTP_PORT: 587

and set the correct value for DISCOURSE_NOTIFICATION_EMAIL (which is likely different from your forum hostname).

TLS and SSL issues

By default, Discourse uses STARTTLS to encrypt its connection to the email server. Some email servers (increasingly rare nowadays) don’t support this or aren’t configured to use it, so it can be disabled by adding this line:

DISCOURSE_SMTP_ENABLE_START_TLS: false    #default: true

Other email servers might support STARTTLS, but use a self-signed certificate. This is uncommon and can be enabled with:

DISCOURSE_SMTP_OPENSSL_VERIFY_MODE: none #default: peer

Email still doesn’t work! What next?

Anything else I forgot here? Feel free to edit this.


Debug issues with first connection to smtp server from inside the Discourse container

1. Enter your container:

./launcher enter app

2. Check dns resolving for your smtp server name via getent hosts:

(dig, nslookup, ping etc. are not installed inside the container.)

getent hosts your.smtp.server

On success, it will look like this or will be blank on failure.

# IPv4
123.123.123.123 your.smtp.server

# IPv6
2001:db8:0:0:0:ff00:42:8329 your.smtp.server

3. Try to open a connection to your smtp server via openssl:

(telnet, nc etc. are not installed inside the container.)

Fiddle with some different settings until you succeed with a connection.

openssl s_client -connect your.smtp.server:465
openssl s_client -connect your.smtp.server:587 -starttls smtp

# IPv4
openssl s_client -connect 172.17.0.123:465
openssl s_client -connect 172.17.0.123:587 -starttls smtp

# IPv6
openssl s_client -6 -connect "[2001:db8:0:0:0:ff00:42:8329]:465"
openssl s_client -6 -connect "[2001:db8:0:0:0:ff00:42:8329]:587" -starttls smtp

See: How to check SMTP connection → Step 3: Checking SMTP Connection Over TLS Using Openssl

4. Use your found working connection settings with Discourse.

:rocket:

Bonus: show Discourse IP from inside docker container

( ifconfig , ip etc. are not installed inside the container.)

hostname -I

Result like:

172.17.0.2

Last edited by @philo 2025-03-04T18:51:41Z

Check documentPerform check on document:
57개의 좋아요
I am not getting any emails
Unable to send email
Mail system not working even thought I tested it with telnet and other platforms
Post Install Email Issues
Installing Discourse on DigitalOcean - got stuck
Activation email not being delivered, test email working
Recommended SMTP provider
Discourse SMTP not receiving mails?
Announcing Discourse Doctor
After Installation Discourse is unable to send Verification email
Email installation issue
No activation email
Discourse SMTP Error
Emails Failing to Send
Errors with Sidekiq - emails not sending
Trouble setting up smtp
Mail server setup
SMTP do not work
Mail error 504 5.7.4 Unrecognized authentication type
Not Receiving Email for Admin Creation
Unable to find verification email
MKJ's Opinionated Discourse Deployment Configuration
Discourse and MailJet issue
Email not sending
All files and directories disappeared from root
Post Install Can't complete email verification
After Installation Discourse is unable to send Verification email
New install email not working "shadowed so this will be ignored"
Email not sending after update
Database shut down error at the end of discourse docker setup
E-Mail not working after moving to self-hosting and adding DKIM record
Email not working with 123-reg and discourse on hosted Virtual Private Server - all other aspects appear to
New users not receiving activation emails
SMTPAuthenticationError: 535 Incorrect authentication data
Issue on Discourse Digest Email
How do I change my primary email
Letters are not sent. What to do?
Sidekiq email errors and settings issue
Noob installation : email not working, trouble with the digitalocean console
SMTPAuthenticationError From Discourse-Doctor On New Install
Outgoing/incoming email changes for our hosted customers
Any MailJet alternatives?
Mail subdomain problem
Emails Failing to Send
Activation Not send
Confusing email documentation
Email jobs failing after latest update, certificate verify failed (unable to get local issuer certificate)
Problems with email
Email Hostname Certificate Mismatch Causing sidekiq Queue Overload, Severe Site Instability
Zoho Mail problems
Cant setup admin account
Understanding mail concept
How to resend activate email when I close the tab
Unable to send email from my forum
Site installed but NO admin email activation
Emails automatically generated from the forum are not working. Any ideas?
./launcher start app - does not run (need to re-setup SMTP)
UNEXPECTED ERROR Net::SMTPAuthenticationError
Discourse-app container starts then silently stops
Fresh Discourse/Docker install wont send mails
Discourse install and SMTP issue
Cannot send email - problem with port 465
Cannot send email - problem with port 465
Will ./launcher destroy app && ./launcher start app remove the built Docker image?
Trying everything, no luck with smtp working
MailJet SMTP is Not Working
SMTPAuthenticationError - I don't receive mail from mailgun to setup the admin account
SMTPAuthenticationError - I don't receive mail from mailgun to setup the admin account
My forum does not send emails
SMTP problem with Amazon SES
I dont know whats wrong with the SMTP service
Problem when updating Discourse Forum
ERROR – 535 auth failure
Troubleshooting Outgoing Email
Backup installation problem?
Yet other SMTP 587 port email various errors
Reset password at command line
Some people are unable to complete the registration, the activate button does not work or the email does not arrive
New setting up and SMTP is not working
Emails not arriving on Gmail
Struggling to Configure SMTP in Discourse with Azure Communication Service
501 5.5.4 You are not allowed to send from this address
Latest version of Discourse not sending Email
Activation Email Not Received for Discourse Admin Account, After Registering User in The Forum
New users not receiving activation emails
Restore a backup from the command line
Unable to Send Admin Emails After Forum Installation
Email not working (SSL_connect returned=1)
Can't Send Emails
Trouble with Email Verification After Discourse Installation
Issue with setting up email: Job exception: Net::SMTPAuthenticationError
:cn: Discourse Official Install Guide | Discourse 云平台安装
Getting up Brevo correctly with Discourse
Cheapest way to run Discourse?
How to change this email
Discourse + DigitalOcean + Mailjet setup
Email for completion not sending because smtp are not correct
Connect SMTP to Discourse
SMTP Mails don't send and connection fails, but openssl works
Issue with creating admin account for first time
ReadTimeout error (No solution)
Issue with creating admin account for first time
Confusing email documentation
Users don't get confirmation e-mail
How Do I Set Up the E-Mail SMTP Server Required for Discourse?
Initial Activation email Not sent. What's wrong with this yaml?
Not Receiving Emails After Successful SMTP Configuration with Neo.Space
Email does not work; Net::SMTPAuthenticationError
Email does not work; Net::SMTPAuthenticationError
What can I do when my users stop receiving verification emails?
Flarum to Discourse Migration with users and discussion
Editing Mail Server
Outlook SMTP Not Working
How to set domain value in Email -> Server Settings
Trouble sending mail via Namecheap Private Email (SMTP) on self-hosted Discourse
Who can help me ? Thanks!有没有人愿意帮我解决一下邮箱问题?
GMail delivery problems: is subdomain discourse.ourdomain.org strictly necessary in outgoing mails?
Not Receiving Admin Verification Email After Setup
Moving from Mailgun to Amazon SES as an amateur
Persistent SMTP Timeout Issue with Spacemail on Discourse (VPS, Docker)
Email delivery configuration checklist
Deploy Discourse without Docker
./discourse-setup puts SMTP username at start of SMTP password
How do I create Discourse forum with docker and VPS?
无法收到邮件的问题
First register email not sent
新安装的discourse无法使用网易邮箱发送验证邮件?
If local logins are disabled
If local logins are disabled
[Résolu] Please les modalités simple pour modifier smtp_password
Configure the new install discourse SMTP Email with Mailgun on AWS Lightsail server
Email not working (SSL_connect returned=1)
I don't receive the activation email to log in as an admin
My Discourse is not sending emails
When i use email :timeout?
Email don't send
Editing posts cause notification
Activation email on Spam
Fresh Discourse/Docker install wont send mails
Installation success but no email
Admin activation E-Mail not sent on fresh self-hosted install (ubuntu 20.04)
Problem with changing password from mail
Problème de réception du mail de confirmation admin (installation sur Hostinger)
Discourse on Azure VM
Email not sending - Domain Spoofing Prohibited
DNS - NameCheap - Mailchimp - sanity check please
How can I change this? smtp
Problem with changing password from mail
Waiting the activation email, been hours still not received
Not getting activation email
I have a question about configuring the mail system
Connecting to a SMTP server on localhost:25 without auth?
SMTP error: Must issue a STARTTLS command first
I have a problem that needs help because the Email can't be sent
Connecting to a SMTP server on localhost:25 without auth?
Email for new user not sent
How might we better structure #howto?
How to change Discourse email settings after installation
Mail doesnt work after installation
Not receiving confirmation email
I did not receive an email to activate my account
Emails are not sent
New signups not receiving welcome email
Discourse with other websites, SMTP issue: End of file reached
Setup wont send me the email
Siteground email
Update failed - Not starting
Email config help
Email delivery configuration checklist
404 Error after installaton
List all users with a given email domain
I created a droplet to install Discourse, what should I do next?

이 정보는 최신 상태인가요? 제 경우엔 작동하지 않아서 SMTP 포트를 변경한 후 앱을 재빌드해야 했습니다.

2개의 좋아요

discourse-doctor가 포트 587으로의 연결이 실패했다고 보고하지만, openssl s_client -connect your.smtp.server:587 -starttls smtp가 정상적으로 작동한다면 다음을 시도해 보세요. 두 명령어 모두 동일한 시간이 걸려야 합니다:

time openssl s_client -starttls smtp -connect your.smtp.server:587 </dev/null > /dev/null

docker run --rm discourse/base:2.0.20231023-1945 bash -c 'time openssl s_client -starttls smtp -connect your.smtp.server:587 </dev/null' > /dev/null

Docker 버전의 실행 시간이 훨씬 더 오래 걸린다면, /etc/docker/daemon.json 파일에 잘못된 설정이 있을 수 있습니다. Google DNS 서버를 첫 번째로 추가해 보실 수 있습니다:

{
  "dns": ["8.8.8.8", "ww.xx.yy.zz", "ww.xx.yy.za"]
}

포트 2525는 Mailjet에서 작동합니다.
587은 실패했습니다.

3개의 좋아요

OP를 수정하여 2525 포트를 사용하도록 제안했습니다. 포트가 차단되는 것은 호스팅 서비스 때문이며, 이로 인해 많은 메일 서비스도 2525 포트를 지원합니다.

4개의 좋아요

여기, 이 부분에 대해 참고할 만한 내용을 하나 추가할게요;

Mailgun은 (본인 외의 수신자에게) 메일을 전달하려면 이제 신용카드 등록을 요구합니다. Mailgun 로그에 “무료 계정” 관련 메시지가 표시된다면, 이는 사용자의 문제입니다.

저는 이번 주(2024년 7월)에 가입했는데, 아직까지 신용카드를 등록하지 않고 기본 무료 플랜으로 잘 사용하고 있습니다. 과거 포럼 게시글들을 살펴본 결과, 이 정책과 무료 플랜의 사용 조건 및 제한 사항에 대해 Mailgun 측이 수시로 입장을 번복하고 있는 것으로 보입니다.

1개의 좋아요

와. 정말 놀랍네요. 제가 기억하는 한, 이전에는 전혀 달랐거든요.

사용자들이 어떻게 하면 사용량 과금(pay-as-you-go) 요금제로 전환할 수 있는지, 그리고 비교적 비싼 월정액 요금제에 가입하지 않고 가입하는 방법을 알아내는 것이 매우 어려웠습니다.

본인 외에 다른 사용자에게도 메일을 보냈나요?

1개의 좋아요

네, 사용자에게 전송했고 정상적으로 작동하고 있습니다. 다만, AOL 이메일 주소에서는 제 이메일이 차단되는 것 같습니다. 하지만 이는 MailGun의 문제가 아니라고 생각합니다. 저도 당신과 마찬가지로 놀라워합니다. :slight_smile:

업데이트: 일부 이메일이 차단되는 이유는 MailGun의 무료 이메일 전송에 사용되는 IP가 공유되기 때문인 것 같습니다. 이로 인해 AOL, Yahoo Mail 등 일부 이메일 플랫폼에서 "스팸"으로 신고되었습니다. Gmail을 사용하지 않는 사용자들은 모두 반송되거나 배달이 거부된 이메일을 받는 것으로 보입니다.

1개의 좋아요

우리 containers/app.yml 파일에서 설정을 확인하는 방법을 설명해 주실 수 있을까요? 우리 같은 초보자들은 명확한 지시 없이 이런 일을 할 줄 몰라요. ㅋㅋ

nano와 같은 도구를 사용하는 방법을 모른다면 discourse-setup을 다시 실행하세요. 변경 사항이 저장된 후에는 control-c를 누르고 다음을 입력하세요.

./launcher destroy app;./launcher start app
1개의 좋아요

네, 그런데 이메일 섹션을 보고 데이터가 올바른지 확인하려면 제 containers/app.yml 파일의 설정을 어떻게 확인해야 하나요?

내 답변이 마음에 들지 않으면 "nano"를 검색해 보세요.

아마도 질문자(OP)가 nano에 대해 언급해야 할 것 같긴 합니다. 제가 말했듯이, nano가 뭔지 모른다면 그냥 discourse-setup을 다시 실행하는 것이 좋습니다. 이 명령은 파일의 값을 읽어들이기 때문에 포맷을 틀릴 일이 없으니까요.

아, 이제 무슨 말씀인지 알겠네요. destroy 명령을 실행한 뒤 start 명령을 실행하면 완료 시점에 필요한 데이터가 표시됩니다. 죄송합니다! :slight_smile:

1개의 좋아요

doctor를 실행했는데 SMTPAuthenticationError라는 오류가 발생했습니다. doctor는 이 오류가 흔하지 않으며 수정 방법에 대한 제안도 없다고 알려줍니다. 이런 일이 발생하면 SMTP 사용자 이름과 비밀번호를 다시 한번 꼼꼼히 확인해 보세요. Discourse 설치 과정에서 비밀번호가 잘못되었다고 알려주지 않기 때문에, 단순히 작동하지 않을 뿐(이메일이 발송되지 않음) 원인을 파악하기가 어렵습니다. 제가 도움이 된 조치 중 하나는 LISH 대신 Ubuntu로 서버에 SSH 접속한 것입니다. (저는 Linode를 사용 중입니다) LISH는 버그가 많고 복사/붙여넣기를 지원하지 않기 때문입니다. 그런 다음 설치 과정을 다시 진행하면서 100자나 되는 비밀번호를 직접 입력하는 대신 이번에는 모든 내용을 복사/붙여넣기로 처리했습니다. 아무튼, 이 글이 같은 초보자인 분들께 도움이 되기를 바랍니다!

사용자 이름 또는 비밀번호가 올바르지 않습니다.

왜 그 오류를 수정하지 못했는지 확실하지 않지만, 오류 메시지는 스스로를 잘 설명하고 있습니다.

잘못 복사/붙여넣기한 것일 수도 있습니다. 이스케이프 처리가 필요한 문자가 포함되어 있을 수도 있습니다.

저는 Brevo를 알림 이메일 전송자로 사용하고 있지만, 보낸 모든 알림이 오류 발생으로 인해 거부되었습니다. Brevo에서 "사용한 발신자가 유효하지 않아 전송이 거부되었습니다. 발신자를 인증하거나 도메인을 인증하십시오"라는 메시지를 확인했습니다. 이로 인해 포럼이 전혀 작동하지 않습니다. 이 문제를 어떻게 해결해야 할지 궁금합니다. 어떤 종류의 발신자가 필요한 것일까요? 정말 감사합니다!!!

발신자 주소는 메일 전송에 사용하는 메일 서브도메인으로 설정할 수 있습니다. 예를 들어 mail@domain_address와 같습니다.

서브도메인과 발신자를 인증하려면 몇 가지 단계를 거쳐야 하며, 해당 가이드는 여기에 있습니다:

디스커스 여러분 안녕하세요!

포트 465로 이메일 매개변수를 설정하는 문제로 며칠 동안 고생했습니다. 이 글이나 포럼에서 읽은 다른 글들(정말 열심히 찾아봤습니다) 어디에도 해결책이 없었습니다.

물론 이는 사용자의 메일 서버가 어떤 것을 허용하는지에 따라 달라집니다. 제 경우를 들어 보면, 오직 465 포트 TLS만 가능합니다.

app.yml에 추가해야 하는 필수 설정 두 줄은 다음과 같습니다:

DISCOURSE_SMTP_FORCE_TLS: true
DISCOURSE_SMTP_ENABLE_START_TLS: false
세부 사항

기본 설정을 사용하면 discourse-doctor로 테스트 이메일을 보내려 할 때 Net::ReadTimeout 오류가 발생했습니다. 컨테이너 내부에서 curl을 사용하여 테스트 이메일을 보내는 것은 이 게시글(해결책의 절반을 알려준 글)과 정확히 같은 방식으로 잘 작동했습니다: Cannot send email - problem with port 465 - #10 by schungx

app.yml의 내용을 보고 해당 매개변수를 수정한 후에야 두 번째 설정에 대해 알 수 있었습니다. 대부분의 프로그램(예: Thunderbird)은 포트 465를 선택할 때 올바른 프로토콜을 암묵적으로 설정하는 것 같아, 디스커스도 그렇게 해야 하는 것 아닐까요? 여기에서 강조하듯 이는 정말로 표준적인 방법입니다:

(전체 게시글 링크)

따라서 이 가이드의 포트 465 관련 섹션을 업데이트하거나 discourse-setup이 최적의 설정을 자동으로 선택하도록 하는 것을 강력히 권장합니다.

3개의 좋아요

보통 이런 식으로 댓글을 달지는 않는데, 정말로 도움이 됐어요!
감사합니다. 이 디스코스의 유지보수자는 이 설정을 기본 구성에 반드시 포함해야 해요. 솔직히 이 소프트웨어를 설정하는 과정이 꽤 번거로웠거든요. 물론这么大的 프로젝트에서는 일부 정보를 바로 얻기 어렵고, 누군가가 “깊이 파고들어야” 한다는 점은 인정합니다.
제가 쓰는 데는 문제없어요!

게시물이 기존 주제에 병합되었습니다: Use of % in SMTP Password for discourse-setup