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

Getting InvalidContentType on send #74

Open
sirlan-ff00ff opened this issue Aug 2, 2023 · 5 comments
Open

Getting InvalidContentType on send #74

sirlan-ff00ff opened this issue Aug 2, 2023 · 5 comments
Assignees
Labels
bug Something isn't working triage

Comments

@sirlan-ff00ff
Copy link

sirlan-ff00ff commented Aug 2, 2023

Describe the bug

When trying to send an email, it doesn't work with a Uncaught InvalidData: received corrupt message of type InvalidContentType

To Reproduce

import { SMTPClient } from "https://deno.land/x/denomailer/mod.ts";

const client = new SMTPClient({
  debug: { log: true },
  connection: {
    hostname: "smtp-relay.brevo.com",
    port: 587,
    tls: true,
    auth: {
      username: "username",
      password: "password",
    },
  },
});

await client.send({
  from: "[email protected]",
  to: "[email protected]",
  subject: "example",
  content: "Oh, hello there",
  html: "<p>Oh, hello there</p>",
});

await client.close();

Expected behavior

Be able to send the email without errors

Logs

Provide the output of deno --version

deno 1.35.3 (release, x86_64-unknown-linux-gnu)
v8 11.6.189.12
typescript 5.1.6

Provide the output of your code snippet (with debug.log set to true see
hhttps://github.com/EC-Nordbund/denomailer#options )

used resolved config
.debug
┌───────────────┬────────┐
│ (idx)         │ Values │
├───────────────┼────────┤
│ log           │ true   │
│ allowUnsecure │ false  │
│ encodeLB      │ false  │
│ noStartTLS    │ false  │
└───────────────┴────────┘
.connection
┌──────────┬──────────────────────────────────────────────────────────────────────────┐
│ (idx)    │ Values                                                                   │
├──────────┼──────────────────────────────────────────────────────────────────────────┤
│ hostname │ "smtp-relay.brevo.com"                                                   │
│ port     │ 587                                                                      │
│ tls      │ true                                                                     │
│ auth     │ '{"username":"username","password":"password"}' │
└──────────┴──────────────────────────────────────────────────────────────────────────┘
.pool
undefined
error: Uncaught InvalidData: received corrupt message of type InvalidContentType
    at async Object.pull (ext:deno_web/06_streams.js:799:27)

Tried using it for both Oracle Cloud Email Delivery and Brevo transactional emails

@sirlan-ff00ff sirlan-ff00ff added bug Something isn't working triage labels Aug 2, 2023
@mrkpatchaa
Copy link

@sirlan-ff00ff having the same issue. Did you find any solution?

@StrawberryChocolateFudge
Copy link

StrawberryChocolateFudge commented Oct 6, 2023

Same issue here.
Edit: The issue is with the port 587 , using 465 it works . Probably the same for OP.

@sirlan-ff00ff
Copy link
Author

Right after posting this I just gave up trying to use it and wrote my own mail sending API thing (just a fancy wrapper over saving the message as /tmp/mail_.txt and using curl to send it)

@Unkn0wn0x
Copy link

Unkn0wn0x commented Oct 20, 2023

Same problem here, except that the provider I use does not support port 465.

Tried every combination, Port 465 / 587, noStartTLS: true / false, tls: true / false, nothing works.

-- EDIT --

I noticed that the command openssl s_client -debug -crlf -connect my-host.com:587 results in the following CIPHER:

New, (NONE), Cipher is (NONE)
This TLS version forbids renegotiation.
Compression: NONE
Expansion: NONE
No ALPN negotiated
Early data was not sent
Verify return code: 0 (ok)

When I run the command openssl s_client -debug -starttls smtp -crlf my-host.com:587 it results in the following CIPHER:

New, TLSv1.3, Cipher is TLS_AES_256_GCM_SHA384
Server public key is 2048 bit
This TLS version forbids renegotiation.
Compression: NONE
Expansion: NONE
No ALPN negotiated
Early data was not sent
Verify return code: 0 (ok)

Could it be possible, that if one of these checks fails, the Denomail throws the error?

@farsightsoftware
Copy link

farsightsoftware commented Dec 29, 2023

I also get the problem, but only intermittently. I'm using port 465.

Update: Our code where this happened was creating an SMTPClient instance (with no pooling options enabled) and keeping it for a long period of time. I can reliably reproduce the problem by just waiting several minutes between emails. This suggests to me that the server is closing the connection, and the next email fails with this error (and a subsequent "BadResource: Bad resource ID" error from deno_web/06_streams.js's Object.write). I haven't experimented with pooling options yet, but just closing the client and creating a new one if it's unused for a period of time seems to work so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

No branches or pull requests

6 participants