CLI email sends fine, Discourse send gets 422


#1

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 525otmzhSu87oi@dkimvalidator.com --from {redacted} --server smtp.socketlabs.com:2525 --auth LOGIN --auth-user server{redacted}
Password: {redacted}
=== Trying smtp.socketlabs.com:2525...
=== Connected to smtp.socketlabs.com.
<-  220 r3.us-west-2a.aws.in.socketlabs.com Hurricane Server ESMTP service ready.
 -> EHLO nbb-rc-1604-2
<-  250-r3.us-west-2a.aws.in.socketlabs.com Hello [{redacted}]
<-  250-PIPELINING
<-  250-SIZE 0
<-  250-ENHANCEDSTATUSCODES
<-  250-STARTTLS
<-  250-AUTH CRAM-MD5 LOGIN
<-  250-AUTH=LOGIN
<-  250 OK
 -> AUTH LOGIN
<-  334 VXNlcm5hbWU6
 -> {redacted}
<-  334 UGFzc3dvcmQ6
 -> {redacted}
<-  235 2.7.0 Accepted.
 -> MAIL FROM:<{redacted}>
<-  250 2.1.0 sender {redacted} OK
 -> RCPT TO:<525otmzhSu87oi@dkimvalidator.com>
<-  250 2.1.5 recipient 525otmzhSu87oi@dkimvalidator.com OK
 -> DATA
<-  354 Send data.  End with CRLF.CRLF
 -> Date: Mon, 10 Sep 2018 05:03:54 +0000
 -> To: 525otmzhSu87oi@dkimvalidator.com
 -> From: {redacted}
 -> Subject: test Mon, 10 Sep 2018 05:03:54 +0000
 -> X-Mailer: swaks v20130209.0 jetmore.org/john/code/swaks/
 -> 
 -> This is a test mailing
 -> 
 -> .
<-  250 2.0.0 Message received and queued as 87000000c634fd.
 -> QUIT
<-  221 r3.us-west-2a.aws.in.socketlabs.com 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"=>"zdukigZ3knVrrK@dkimvalidator.com"}
Sent mail to zdukigZ3knVrrK@dkimvalidator.com (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 (.


#3

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 http://www.mail-tester.com/
Or just send a test message to yourself.
Email address for mail test? ('n' to skip) [me@example.com]: {redacted}
Sending mail to {redacted}. . . 
Testing sending to {redacted} using {redacted}:{redacted}@smtp.socketlabs.com:2525.
SMTP server connection successful.
Sending to {redacted}. . . 
Sending mail failed.
Replacing: SMTP_PASSWORD
Replacing: LETSENCRYPT_ACCOUNT_EMAIL
Replacing: DEVELOPER_EMAILS
Replacing: DISCOURSE_DB_PASSWORD
Replacing: Sending mail to

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

And in the linked error file:

==================== MAIL TEST ====================
For a robust test, get an address from http://www.mail-tester.com/
Sending mail to REDACTED  . . 
Testing sending to {redacted} using
{redacted}:{redacted}@smtp.socketlabs.com:2525.
SMTP server connection successful.
Sending to {redacted}. . . 
Sending mail failed.

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

#4

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 https://serversmtp.com/smtp-error/, 422 for an SMTP server means:

The recipient’s mailbox has exceeded its storage limit.

Could that be true?


(Michael - DiscourseHosting.com) #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.


#8

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

…and then I start crying.

:wink:


#9

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.