Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to send mails with smtps://smtp-relay.gmail.com:465 #2425

Closed
3 of 6 tasks
vizv opened this issue Apr 25, 2022 · 0 comments
Closed
3 of 6 tasks

Unable to send mails with smtps://smtp-relay.gmail.com:465 #2425

vizv opened this issue Apr 25, 2022 · 0 comments
Labels
bug Something is not working.

Comments

@vizv
Copy link
Contributor

vizv commented Apr 25, 2022

Preflight checklist

Describe the bug

Unable to send mails with smtps://smtp-relay.gmail.com:465

See below for relevant configuration, context, and workaround

also attach this ticket to #781

Reproducing the bug

Configure courier.smtp.connection_uri to smtps://<g-suite email address>:<application token>@smtp-relay.gmail.com:465/ and send any email (verification / recover / ...)

Relevant log output

No output but netstat shows the courier is continuously attempting to send the mail out.

However when setting RetryFailure: false for gomail.Dialer in courier/smtp.go, I'm able to get error like:

func=github.com/ory/kratos/courier.(*courier).dispatchEmail
file=/go/src/github.com/ory/kratos/courier/smtp.go:184
error=map[message:gomail: could not send email 1: EOF stack_trace:stack trace could not be recovered from error type *mail.SendError]

Relevant configuration

courier:
  smtp:
    connection_uri: smtps://fake@domain.tld:fake-token@smtp-relay.gmail.com:465/

Version

v0.9.0-alpha.3

On which operating system are you observing this issue?

Linux

In which environment are you deploying?

Kubernetes with Helm

Additional Context

After hacking around, I found the issue is caused by ory/mail module trying to handshake with gmail relay server with EHLO localhost since LocalName of the smtp dailer is not set (and localhost is the default local name) but gmail doesn't like it:

if I use openssl to establish an SSL connection with the server and send EHLO localhost, it will return 421 and hang up immediately:

openssl s_client -crlf -connect smtp-relay.gmail.com:465
...
220 smtp-relay.gmail.com ESMTP v9-... - gsmtp
EHLO localhost
421 4.7.0 Try again later, closing connection. (EHLO) v9-... - gsmtp
read:errno=0

similar to https://stackoverflow.com/questions/65721463/phpmailer-not-sending-emails-from-localhost-using-gmails-smtp

However the current implementation doesn't support setting LocalName from config, in fact I tried to hard-code LocalName to "kratos" and it just works.

Another minor issue is RetryFailure: true makes back-off strategy not working as expected, for smtps://smtp-relay.gmail.com:465 it's continuously re-establishing connection silently and never stops or back-off exponentially.

@vizv vizv added the bug Something is not working. label Apr 25, 2022
peturgeorgievv pushed a commit to senteca/kratos-fork that referenced this issue Jun 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working.
Projects
None yet
Development

No branches or pull requests

1 participant