CLI email sends fine, Discourse send gets 422


I can send an email from the CLI [1], but when I send from Discourse [2] I get this 422 error which to me is too non-specific to figure out. Credentials, servername, port are the same in both cases. Help?

[1] ========== CLI send, works and email is received ==========

$swaks --to --from {redacted} --server --auth LOGIN --auth-user server{redacted}
Password: {redacted}
=== Trying
=== Connected to
<-  220 Hurricane Server ESMTP service ready.
 -> EHLO nbb-rc-1604-2
<- Hello [{redacted}]
<-  250-SIZE 0
<-  250-STARTTLS
<-  250-AUTH=LOGIN
<-  250 OK
<-  334 VXNlcm5hbWU6
 -> {redacted}
<-  334 UGFzc3dvcmQ6
 -> {redacted}
<-  235 2.7.0 Accepted.
 -> MAIL FROM:<{redacted}>
<-  250 2.1.0 sender {redacted} OK
 -> RCPT TO:<>
<-  250 2.1.5 recipient OK
 -> DATA
<-  354 Send data.  End with CRLF.CRLF
 -> Date: Mon, 10 Sep 2018 05:03:54 +0000
 -> To:
 -> From: {redacted}
 -> Subject: test Mon, 10 Sep 2018 05:03:54 +0000
 -> X-Mailer: swaks v20130209.0
 -> This is a test mailing
 -> .
<-  250 2.0.0 Message received and queued as 87000000c634fd.
 -> QUIT
<-  221 Closing. Have a good day.
=== Connection closed with remote host.

[2] ========== Discourse send, fails ==========

Started POST "/admin/email/test" for {redacted} at 2018-09-10 05:11:15 +0000
Processing by Admin::EmailController#test as */*
  Parameters: {"email_address"=>""}
Sent mail to (830.2ms)
Completed 422 Unprocessable Entity in 1106ms (Views: 0.2ms | ActiveRecord: 4.2ms)

(Jay Pfaffman) #2

You might try discourse-doctor (or the rake task that it calls (.


Well, yeah. I did use Discourse Doctor, but it gave an even more opaque result:

==================== MAIL TEST ====================
For a robust test, get an address from
Or just send a test message to yourself.
Email address for mail test? ('n' to skip) []: {redacted}
Sending mail to {redacted}. . . 
Testing sending to {redacted} using {redacted}:{redacted}
SMTP server connection successful.
Sending to {redacted}. . . 
Sending mail failed.
Replacing: Sending mail to

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

And in the linked error file:

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

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


I guess what I am looking for is a smtp session log like what swaks gives. Or some actual error trace…

Looking at the Discourse forum, the “422” error is usually a result of 2FA or other unusual auth requirements of the various SMTP providers. In my case, I am using the simplest and most widely used transactional email provider that exists, to which I can send just fine from CLI.

(Jay Pfaffman) #5

Hmm. Thanks very much for the info. I just started coming up with whatever errors Discourse doctor can catch and diagnose.

According to, 422 for an SMTP server means:

The recipient’s mailbox has exceeded its storage limit.

Could that be true?

(Michael - #6

The 422 is an HTTP error (Unprocessable Entity), not a SMTP error.

Since sending through CLI goes well, this must be on the Discourse web app side.

(Jay Pfaffman) #7

But his above message from discourse-doctor did fail. His success was from swaks, not Discourse.


I am going to guess that the issue is along these lines:

…and then I start crying.



That said, I would NEXT guess that I have an environment issue… which means reinstall. Sigh. So, that is my next step barring any other input. I’ll tell you all how it goes.