SMTP for AWS

I’m trying to get kobo’s automated email function to work with AWS SMTP settings. When I build kobo I enter the settings and after they appear in the smtp.txt file

EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
EMAIL_HOST=email-smtp.eu-west-1.amazonaws.com
EMAIL_PORT=465
EMAIL_HOST_USER=user@mydomain.com
EMAIL_HOST_PASSWORD=USER-PASSWORD
EMAIL_USE_TLS=True
DEFAULT_FROM_EMAIL=user@mydomain.com

This doesn’t work and I get a 500 error when trying to register as a new user. However when I enter settings for a Zoho account I have everything works as expected.

So I test the AWS SMTP settings using swaks. When I use tls I get

swaks --to me@gmail.com -f user@mydomain.com -s smtp.mail.eu-west-1.awsapps.com --port 465 -tls -a LOGIN
Username: user@mydomain.com
Password: USER-PASSWORD
=== Trying smtp.mail.eu-west-1.awsapps.com:465...
=== Connected to smtp.mail.eu-west-1.awsapps.com.
<** Timeout (30 secs) waiting for server response
 -> QUIT
<** Timeout (30 secs) waiting for server response
=== Connection closed with remote host.

However when I use tls-on-connect (-tlsc) it works as expected, I receive an email to my gmail account, which shows that the AWS SMTP settings work.

swaks --to me@gmail.com -f user@mydomain.com -s smtp.mail.eu-west-1.awsapps.com --port 465 -tlsc -a LOGIN
Username: user@mydomain.com
Password: USER-PASSWORD
=== Trying smtp.mail.eu-west-1.awsapps.com:465...
=== Connected to smtp.mail.eu-west-1.awsapps.com.
=== TLS started with cipher TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128
=== TLS no local certificate set
=== TLS peer DN="/CN=smtp.mail.eu-west-1.awsapps.com"
<~  220 smtp.eu-west-1.mail.awsapps.com ESMTP Amazon WorkMail SMTP Service
 ~> EHLO ip-10-0-0-245.eu-west-1.compute.internal
<~  250-smtp.eu-west-1.mail.awsapps.com
<~  250-8BITMIME
<~  250-AUTH PLAIN LOGIN
<~  250 Ok
 ~> AUTH LOGIN
<~  334 VXNlcm5hbWU6
 ~> aGhsQG9wZW5wbGFuaXQuY29t
<~  334 UGFzc3dvcmQ6
 ~> TzJhSjZDZUhMQTNVUHl4aElvaks=
<~  235 Authentication successful.
 ~> MAIL FROM:<user@mydomain.com>
<~  250 Ok
 ~> RCPT TO:<me@gmail.com>
<~  250 Ok
 ~> DATA
<~  354 End data with <CR><LF>.<CR><LF>
 ~> Date: Wed, 07 Dec 2022 10:52:47 +0000
 ~> To: me@gmail.com
 ~> From: user@mydomain.com
 ~> Subject: test Wed, 07 Dec 2022 10:52:47 +0000
 ~> Message-Id: <20221207105247.013749@ip-10-0-0-245.eu-west-1.compute.internal>
 ~> X-Mailer: swaks v20201014.0 jetmore.org/john/code/swaks/
 ~> 
 ~> This is a test mailing
 ~> 
 ~> 
 ~> .
<~  250 Ok
 ~> QUIT
<~  221 Bye
=== Connection closed with remote host.

Is there some issue with django.core.mail.backends.smtp.EmailBackend and AWS SMTP?

Does anyone have AWS SMTP working in kobo?

@dyq, linking you with @stephenoduor @ks_1, who might be available for support.