Skip to content

Cleartext SMTP doesn't work #4498

@altafard

Description

@altafard

Preflight checklist

Ory Network Project

No response

Describe the bug

Hey there,

According to the documentation,

Cleartext SMTP uses no encryption and is not secure. This option is often used in development environments:
smtp://username:password@server:port/?disable_starttls=true

I use SMTP connection as stated in the quote: smtp://test:test@mailpit:1025/?disable_starttls=true

Instead of Mailslurper I run Mailpit, and as you can see, it's unprotected and don't use TLS (I'm trying to run it in my local development environment).

  mailpit:
    image: axllent/mailpit:v1.27
    container_name: mailpit
    restart: unless-stopped
    ports:
      - '8025:8025' # Web UI
      - '1025:1025' # SMTP
    environment:
      - MP_DISABLE_VERSION_CHECK=true
      - MP_MAX_MESSAGES=100
      - MP_SMTP_AUTH_ACCEPT_ANY=true
      - MP_SMTP_REQUIRE_STARTTLS=false
      - MP_SMTP_REQUIRE_TLS=false
      - MP_SMTP_AUTH_ALLOW_INSECURE=true
      - MP_VERBOSE=true
    networks:
      - intranet

However, Kratos cannot send emails due to an error: unencrypted connection reason:failed to send email via smtp.

Reproducing the bug

docker-compose.development.yaml

kratos.yml

Relevant log output

time=2025-11-09T01:34:04Z level=error msg=Unable to dial SMTP connection. func=github.com/ory/kratos/courier.(*SMTPChannel).Dispatch file=/project/courier/smtp_channel.go:130 audience=application error=map[message:unencrypted connection stack_trace:stack trace could not be recovered from error type *errors.errorString] message_from=***** message_id=a57c54a0-4c99-44cb-b95f-1071bf5300c4 message_nid=7af98daf-5a53-4fd0-abe6-d8c0167a4bec message_subject=***** message_template_type=recovery_code_valid message_type=email service_name=Ory Kratos service_version=v25.4.0 smtp_server=mailpit:1025 smtp_ssl_enabled=false trace_id=00000000000000000000000000000000
2025-11-09T01:34:04.892387356Z time=2025-11-09T01:34:04Z level=warning msg=Unable to dispatch message. func=github.com/ory/kratos/courier.(*courier).DispatchQueue file=/project/courier/courier_dispatcher.go:137 audience=application error=map[debug: message:unencrypted connection reason:failed to send email via smtp stack_trace:
2025-11-09T01:34:04.892391731Z github.com/ory/kratos/courier.(*SMTPChannel).Dispatch
2025-11-09T01:34:04.892394856Z 	/project/courier/smtp_channel.go:131
2025-11-09T01:34:04.892397981Z github.com/ory/kratos/courier.(*courier).DispatchMessage
2025-11-09T01:34:04.892401731Z 	/project/courier/courier_dispatcher.go:79
2025-11-09T01:34:04.892404481Z github.com/ory/kratos/courier.(*courier).DispatchQueue
2025-11-09T01:34:04.892407230Z 	/project/courier/courier_dispatcher.go:134
2025-11-09T01:34:04.892410022Z github.com/ory/kratos/courier.(*courier).watchMessages.func1
2025-11-09T01:34:04.892412814Z 	/project/courier/courier.go:99
2025-11-09T01:34:04.892415522Z github.com/cenkalti/backoff.RetryNotify
2025-11-09T01:34:04.892418188Z 	/go/pkg/mod/github.com/cenkalti/backoff@v2.2.1+incompatible/retry.go:37
2025-11-09T01:34:04.892421063Z github.com/cenkalti/backoff.Retry
2025-11-09T01:34:04.892423688Z 	/go/pkg/mod/github.com/cenkalti/backoff@v2.2.1+incompatible/retry.go:24
2025-11-09T01:34:04.892433855Z github.com/ory/kratos/courier.(*courier).watchMessages
2025-11-09T01:34:04.892436271Z 	/project/courier/courier.go:98
2025-11-09T01:34:04.892438438Z runtime.goexit
2025-11-09T01:34:04.892441146Z 	/usr/local/go/src/runtime/asm_arm64.s:1268 status:Internal Server Error status_code:500] message_id=a57c54a0-4c99-44cb-b95f-1071bf5300c4 message_nid=7af98daf-5a53-4fd0-abe6-d8c0167a4bec message_subject=***** message_template_type=recovery_code_valid message_type=email service_name=Ory Kratos service_version=v25.4.0

Relevant configuration

courier:
  delivery_strategy: smtp
  smtp:
    connection_uri: smtp://test:test@mailpit:1025/?disable_starttls=true

Version

v25.4.0

On which operating system are you observing this issue?

macOS

In which environment are you deploying?

Docker Compose

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is not working.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions