Fehlerbehebung bei E-Mails auf einer neuen Discourse-Installation

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

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) is largely deprecated in favor of STARTTLS on 25. You may 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_SMTP_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 „Gefällt mir“
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
Announcing Discourse Doctor
Recommended SMTP provider
Discourse SMTP not receiving mails?
MKJ's Opinionated Discourse Deployment Configuration
After Installation Discourse is unable to send Verification email
Not Receiving Email for Admin Creation
No activation email
Mail error 504 5.7.4 Unrecognized authentication type
Mail server setup
Trouble setting up smtp
Discourse and MailJet issue
All files and directories disappeared from root
Email not sending
Emails Failing to Send
Discourse SMTP Error
Email installation issue
SMTP do not work
Post Install Can't complete email verification
Errors with Sidekiq - emails not sending
My Discourse is not sending emails
Unable to find verification email
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
Email jobs failing after latest update, certificate verify failed (unable to get local issuer certificate)
Problems with email
Email not working (SSL_connect returned=1)
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
I don't receive the activation email to log in as an admin
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
When i use email :timeout?
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
Latest version of Discourse not sending Email
Persistent SMTP Timeout Issue with Spacemail on Discourse (VPS, Docker)
Email delivery configuration checklist
How to change Discourse email settings after installation
Deploy Discourse without Docker
./discourse-setup puts SMTP username at start of SMTP password
[Résolu] Please les modalités simple pour modifier smtp_password
How do I create Discourse forum with docker and VPS?
Confusing email documentation
无法收到邮件的问题
新安装的discourse无法使用网易邮箱发送验证邮件?
Moving from Mailgun to Amazon SES as an amateur
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?
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?
After Installation Discourse is unable to send Verification email
New install email not working "shadowed so this will be ignored"

Sind dies aktuelle Informationen? Es hat bei mir nicht funktioniert; ich musste die App neu aufbauen, nachdem ich den SMTP-Port geändert hatte.

2 „Gefällt mir“

Wenn discourse-doctor meldet, dass die Verbindung zu Port 587 fehlgeschlagen ist, aber openssl s_client -connect your.smtp.server:587 -starttls smtp einwandfrei funktioniert, versuchen Sie Folgendes. Beide Befehle sollten ungefähr die gleiche Zeit benötigen:

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

Wenn die Docker-Version deutlich länger dauert, haben Sie möglicherweise eine falsche Konfiguration in Ihrer /etc/docker/daemon.json-Datei. Sie können versuchen, den Google Nameserver an erster Stelle zu setzen:

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

Port 2525 funktioniert für Mailjet.
587 ist fehlgeschlagen.

2 „Gefällt mir“

Ich habe die OP bearbeitet, um die Verwendung von Port 2525 vorzuschlagen. Es ist Ihr Hosting-Dienst, der den Port blockiert. Aus diesem Grund unterstützen viele E-Mail-Dienste auch 2525.

3 „Gefällt mir“

Hallo, ich wollte nur eine Anmerkung dazu machen;

Mailgun verlangt jetzt eine Kreditkarte, um E-Mails zuzustellen (außer an Sie selbst). Wenn Ihre Mailgun-Protokolle eine Nachricht über „kostenlose Konten“ enthalten, ist dies Ihr Problem.

Ich habe mich diese Woche (Juli 2024) angemeldet und bisher funktioniert es, ohne eine Kreditkarte hinzufügen zu müssen, und nutzt die kostenlose Basisebene. Basierend auf dem, was ich in alten Forum-Threads gesehen habe, scheint es, dass sie diese Richtlinie und die Nutzung und Einschränkungen ihrer kostenlosen Ebenen hin und her geändert haben, vielleicht

1 „Gefällt mir“

Wow. Das ist verrückt und ganz anders, als es seit jeher war.

Es war sehr schwierig für die Leute herauszufinden, wie sie zum Pay-as-you-go-Plan wechseln und nicht einen ziemlich teuren Monatsplan abschließen konnten.

Hast du an andere Benutzer als dich selbst gesendet?

1 „Gefällt mir“

Ja, ich habe es an Benutzer gesendet und es funktioniert. Das einzige Problem ist, dass AOL-E-Mail-Adressen aus irgendeinem Grund meine E-Mails blockieren, aber ich glaube nicht, dass das die Schuld von MailGun ist. Ich bin genauso überrascht wie Sie :slight_smile:

Update: Es scheint, dass der Grund, warum einige E-Mails blockiert werden, darin liegt, dass die IP-Adresse, die für das Senden kostenloser E-Mails von MailGun verwendet wird, gemeinsam genutzt wird. Daher wurde sie von einigen E-Mail-Plattformen wie AOL, Yahoo Mail und anderen als „Spam“ gemeldet. Es scheint, dass jeder, der nicht Gmail verwendet, zurückgewiesene oder abgelehnte E-Mail-Zustellungen sieht.

1 „Gefällt mir“

Können Sie bitte erklären, wie wir die Einstellungen in unserer containers/app.yml-Datei überprüfen können? Wir Neulinge wissen ohne ausdrückliche Anweisung nicht, wie man diese Dinge tut. lol

Wenn Sie nicht wissen, wie Sie ein Tool wie nano verwenden, führen Sie discourse-setup erneut aus. Nachdem die Änderungen gespeichert wurden, können Sie Strg+C drücken und dann

./launcher destroy app;./launcher start app
1 „Gefällt mir“

ok, aber wie überprüfe ich die Einstellungen in meiner containers/app.yml-Datei, damit ich den E-Mail-Bereich ansehen und die Daten auf Korrektheit überprüfen kann?

Wenn Ihnen meine Antwort nicht gefällt, können Sie nach „nano“ googeln.

Man könnte argumentieren, dass der OP etwas über Nano sagen sollte, obwohl, wie ich bereits sagte, wenn Sie nicht wissen, was es ist, dann führen Sie einfach discourse-setup erneut aus, da es die Werte in der Datei liest und Sie das Format nicht durcheinander bringen können.

Ich verstehe jetzt, was Sie meinen. Wenn Sie die Befehle „destroy“ und dann „start“ ausführen, werden die benötigten Daten nach Abschluss angezeigt. Entschuldigen Sie vielmals! :slight_smile:

1 „Gefällt mir“

Ich habe den Doctor ausgeführt und eine Fehlermeldung erhalten, die SMTPAuthenticationError lautet. Der Doctor sagt dann, dass dies kein häufiger Fehler sei und sie keine Vorschläge zur Behebung hätten. Wenn dies passiert, stellen Sie sicher, dass Sie Ihren SMTP-Benutzernamen und Ihr Passwort noch einmal überprüfen, da der Discourse-Einrichtungsprozess Ihnen nicht mitteilt, ob es falsch ist. Es funktioniert einfach nicht (sendet keine E-Mails) und lässt Sie ratlos zurück. Einige Dinge, die ich getan habe und die geholfen haben, waren, mich mit SSH auf meinem Server über Ubuntu anstatt LISH anzumelden (da ich Linode benutze), weil LISH schrecklich fehlerhaft ist und keine Kopie/Einfügen-Funktion unterstützt. Ich habe dann den Einrichtungsprozess wiederholt und diesmal alles kopiert und eingefügt, anstatt 100 Zeichen lange Passwörter einzugeben, lol. Ich hoffe, das hilft einigen meiner Mit-Noobs da draußen!

Ihr Benutzername oder Ihr Passwort ist falsch.

Ich bin mir nicht sicher, warum ich das nicht beheben konnte, aber der Fehler ist ziemlich selbsterklärend.

Es könnte sein, dass Sie ihn falsch kopiert und eingefügt haben. Es könnte sein, dass er Zeichen enthält, die maskiert werden müssen.

Ich verwende Brevo als meinen Benachrichtigungs-E-Mail-Absender, aber jede einzelne Benachrichtigung wurde aufgrund eines Fehlers abgelehnt. Ich habe eine Nachricht in Brevo gefunden, in der steht: „Das Senden wurde abgelehnt, da der von Ihnen verwendete Absender nicht gültig ist. Validieren Sie Ihren Absender oder authentifizieren Sie Ihre Domain“. Aus diesem Grund kann mein Forum überhaupt nicht funktionieren. Ich frage mich, wie ich das beheben kann – welche Art von Absender benötige ich? Vielen Dank!!!

Für die Absenderadresse kann die Mail-Subdomain, die Sie zum Senden von E-Mails verwenden, festgelegt werden, z. B. mail@domain_address.

Um die Subdomain + den Absender zu authentifizieren, sind einige Schritte erforderlich. Hier gibt es eine Anleitung:

Hallo Discourse-Leute!

Ich habe tagelang damit gekämpft, die E-Mail-Parameter mit Port 465 einzurichten, und die Lösung ist weder hier noch in irgendeinem Beitrag, den ich im Forum gelesen habe (und ich habe wirklich recherchiert).

Natürlich ist es eine Frage dessen, was Ihr Mailserver akzeptiert. In meinem Fall nur 465 über TLS.

Die zwei erforderlichen Konfigurationszeilen, die zu app.yml hinzugefügt werden müssen, sind:

DISCOURSE_SMTP_FORCE_TLS: true
DISCOURSE_SMTP_ENABLE_START_TLS: false
Einige Details

Die Standardeinstellungen führten zu einem Net::ReadTimeout-Fehler, als ich versuchte, eine Test-E-Mail mit discourse-doctor zu senden. Das Senden von Test-E-Mails aus dem Container heraus funktioniert mit z. B. curl einwandfrei, genau wie in diesem Beitrag, der mich zur halben Lösung führte: Cannot send email - problem with port 465 - #10 by schungx

Über die zweite Einstellung konnte ich nur herausfinden, indem ich den Inhalt von app.yml durchgesehen und diesen Parameter geändert habe. Ich habe das Gefühl, dass die meisten Programme (z. B. Thunderbird) das richtige Protokoll implizit auswählen, wenn Port 465 ausgewählt wird, vielleicht sollte Discourse das auch tun? Dies scheint wirklich Standard zu sein, wie auch hier hervorgehoben:

(Link zum vollständigen Beitrag)

Daher würde ich wirklich dafür plädieren, den Abschnitt dieser Anleitung über Port 465 zu aktualisieren oder discourse-setup automatisch die beste Einstellung wählen zu lassen.

2 „Gefällt mir“

Normalerweise kommentiere ich nichts, aber das war tatsächlich hilfreich!
Danke Mann, der Betreuer des Diskurses sollte diese Einstellung unbedingt in die Standardkonfiguration aufnehmen, ich meine, es war mühsam, ihre Software einzurichten, trotzdem habe ich nichts zu kritisieren, außer dass bei einem so großen Projekt einige Informationen nicht schnell verfügbar sind und jemand “tief eintauchen” muss.
OK funktioniert für mich!

Ein Beitrag wurde in ein bestehendes Thema eingefügt: Verwendung von % im SMTP-Passwort für discourse-setup