denomailer
denomailer copied to clipboard
Getting `InvalidContentType` on send
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 having the same issue. Did you find any solution?
Same issue here. Edit: The issue is with the port 587 , using 465 it works . Probably the same for OP.
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_
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?
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.