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

I’m getting the following error using ./discourse-docker on Digital Ocean after installation

==================== MAIL TEST ====================
For a robust test, get an address from http://www.mail-tester.com/
Or just send a test message to yourself.
Email address for mail test? ('n' to skip) [forum@jamaicans.dev]: 
Sending mail to forum@jamaicans.dev. . . 
Testing sending to forum@jamaicans.dev using mail.jamaicans.dev:587.
======================================== ERROR ========================================
                                    UNEXPECTED ERROR

500 5.5.1 Invalid command
1 Like

is forum@jamaicans.dev a valid email Address?
Are you using a custom SMTP?

Yes, I’m running my own Mail server using Mailu -> Mailu — Mailu, Docker based mail server.

I wrote a python script to test if it is send emails using the SMTP credentials, and I’m able to send and receive emails. I also tried Telnet, which works. The port is running on 587 with StartTLS. DMARC and SPF has already been setup.

The mail account has a % sign in the password. I noticed in the app.yaml that the passowrd shouldn’t have in a #. Do you think this would be the culprit?

Enclose the password in Quotes e.g. 'P@$$w0RD%100' that should make it work

It is already enclosed

Why not change the password and find out?

I did, waiting on the rebuild to complete… but just in case it fails, I wanted to find out if anyone else got this message

It didn’t work. I’ll probably just use mail gun

Can you share your Python script? I, too, installed mailu, and I like to test it.

Update: Nevermind, I created it myself via Sending Emails With Python – Real Python. Mailu works (without TLS, as I haven’t figured out how to use letsencrypt with both mailu and caddy), but discourse doesn’t send emails …


It also worked for me. I made some changes to mail settings and it started to work. Sorry for not indicating that I got it to work.


I got it working, too. Testing it with discourse-doctor helped a lot.


I have the same error. Do either of you remember what you did to fix it?

Honestly, no, but try to get it working with example seen in real python first. I think this led me to the solution.

1 Like