EC-Nordbund / denomailer

A SMTP-Client implementation for deno (to send mails!)
https://deno.land/x/denomailer
MIT License
52 stars 17 forks source link

Timeout on deno Deploy #17

Closed Benoit-Vasseur closed 2 years ago

Benoit-Vasseur commented 2 years ago

Describe the bug

On my local machine the sending is working fine. However I deploy my app to deno deploy and in this environment I have a timeout :/

I tried multiple port : 25 or 465 but I have the same timeout in Deno deploy env.

TimedOut: Connection timed out (os error 110)     at async Object.connect (deno:ext/net/01_net.js:333:17)     at async SMTPConnection.#connect (https://deno.land/x/denomailer@1.0.0/client/basic/connection.ts:34:25)     at async https://deno.land/x/denomailer@1.0.0/client/basic/client.ts:45:13

To Reproduce

Deploy an app to deno Deploy.

Expected behavior

No timeout

Logs

Locally, when I create the client I have the log :

220 mail.infomaniak.com ESMTP ready
┌───────┬───────────────────────┐
│ (idx) │ Values                │
├───────┼───────────────────────┤
│     0 │ "EHLO"                │
│     1 │ "mail.infomaniak.com" │
└───────┴───────────────────────┘
250-mail.infomaniak.com
250-PIPELINING
250-SIZE
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-DSN
250-AUTH PLAIN LOGIN
250 STARTTLS

And others logs when I send the email (the sending is working locally).

But in deno deploy my last log is :

.pool
┌──────────┬─────────────────────────────────────────────────────────────────────────┐
│ (idx)    │ Values                                                                  │
├──────────┼─────────────────────────────────────────────────────────────────────────┤
│ hostname │ "mail.infomaniak.com"                                                   │
│ port     │ 25                                                                      │
│ tls      │ false                                                                   │
│ auth     │ '{"username":"xxx","password":"xxx"}' │
└──────────┴─────────────────────────────────────────────────────────────────────────┘

No other logs and I have a timeout when I try to send an email

STARTTLS

openssl s_client -debug -starttls smtp -crlf -connect mail.infomaniak.com:25 startTls.txt

TLS

openssl s_client -debug -crlf -connect mail.infomaniak.com:25 tls_port_25.txt

Port 465 seems better.

openssl s_client -debug -crlf -connect mail.infomaniak.com:465 tls_port_465.txt

mathe42 commented 2 years ago

I will have to try it out. Never used Deno deploy.

Could you tell me If you used the pool options?

mathe42 commented 2 years ago

So don't expect a fix in the next days....

louiszgn commented 2 years ago

Hi 👋 I have exactly the same issue. I can send a mail locally but not in Deno Deploy. The provider is Gmail.

Could you tell me If you used the pool options?

I did not.

This is the logs I have :

TimedOut: Connection timed out (os error 110)
    at async Object.connectTls (deno:ext/net/02_tls.js:46:17)
    at async SMTPConnection.#connect (https://deno.land/x/denomailer@1.0.0/client/basic/connection.ts:28:25)
    at async https://deno.land/x/denomailer@1.0.0/client/basic/client.ts:45:13
    at async SMTPClient.send (https://deno.land/x/denomailer@1.0.0/client/basic/client.ts:60:9)
undefined
.pool
┌──────────┬────────────────────────────────────────────────────────────────────┐
│ (idx)    │ Values                                                             │
├──────────┼────────────────────────────────────────────────────────────────────┤
│ hostname │ "smtp.gmail.com"                                                   │
│ port     │ 465                                                                │
│ tls      │ true                                                               │
│ auth     │ '{"username":"XXXXX@gmail.com","password":"XXXXX"}' │
└──────────┴────────────────────────────────────────────────────────────────────┘
.connection
┌───────────────┬────────┐
│ (idx)         │ Values │
├───────────────┼────────┤
│ log           │ true   │
│ allowUnsecure │ false  │
│ encodeLB      │ true   │
│ noStartTLS    │ false  │
└───────────────┴────────┘
.debug
used resolved config
mathe42 commented 2 years ago

Sorry didnt had time to look into it.

mathe42 commented 2 years ago

Could you try Just a Deno.connect or Deno.connectTLS to your SMTP Server in Deno deploy...

mathe42 commented 2 years ago

I could create a reproduction with

const conn = await Deno.connectTls({hostname: "smtp.gmail.com", port: 465 })
await conn.handshake()

console.log('DONE')

Currently checking if problem at connect or at handshake

mathe42 commented 2 years ago

Created an issue upstream https://github.com/denoland/deploy_feedback/issues/194. I leave this open until it is resolved.

mathe42 commented 2 years ago

Sorry but

See https://discord.com/channels/684898665143206084/684911491035430919/961964433524031498

You can not connect to SMTP servers on ports 25, 465, or 587 due to abuse. we have an internal issue open to improve the error message

so that is something I can't fix. will add an info to the readme

Benoit-Vasseur commented 2 years ago

I let the default for pool.

Le 2022-04-26T23:05:12.000+02:00, Sebastian Krüger @.***> a écrit :

 I will have to try it out. Never used Deno deploy.    Could you tell me If you used the pool options?    —  Reply to this email directly, view it on GitHub  [https://github.com/EC-Nordbund/denomailer/issues/17#issuecomment-1110247518],  or unsubscribe  [https://github.com/notifications/unsubscribe-auth/AAKRSBZCJLIKAAQFIMFHTLLVHBLARANCNFSM5UM7NEGA].  You are receiving this because you authored the thread.Message ID: @.***>

mathe42 commented 2 years ago

@Benoit-Vasseur I closed this as this is an limitation with deno deploy

If your SMTP server uses ports 25, 465, or 587 you can't use denomailer with Deno Deploy. See https://discord.com/channels/684898665143206084/684911491035430919/961964433524031498 for more info.

"You can not connect to SMTP servers on ports 25, 465, or 587 due to abuse."