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

connectTLS not working #2

Closed jupegarnica closed 2 years ago

jupegarnica commented 2 years ago

image

mathe42 commented 2 years ago

Could you please provie a full (but minimal) reproduction. And the output of deno --version ?

jupegarnica commented 2 years ago

sure! It is the example from the readme

Code:

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

const client = new SmtpClient();

const options = ({
  hostname: "smtp.mailersend.net",
  port: Number("587"),
  username: "XXXX",
  password: "XXXX",
});

await client.connectTLS(options);

await client.send({
  from: "XXX@XXX.dev",
  to: "XXXX@XXX.com",
  subject: "Mail Title",
  content: "Mail Content",
  html: "<a href='https://github.com'>Github</a>",
});

await client.close();

Host:


➜ deno --version                
deno 1.19.3 (release, x86_64-unknown-linux-gnu)
v8 9.9.115.8
typescript 4.5.2

Error:

error: Uncaught (in promise) DenoStdInternalError: bufio: caught error from `readSlice()` without `partial` property
    throw new DenoStdInternalError(msg);
          ^
    at assert (https://deno.land/std@0.104.0/_util/assert.ts:13:11)
    at BufReader.readLine (https://deno.land/std@0.104.0/io/bufio.ts:259:7)
    at async TextProtoReader.readLineSlice (https://deno.land/std@0.104.0/textproto/mod.ts:131:11)
    at async TextProtoReader.readLine (https://deno.land/std@0.104.0/textproto/mod.ts:33:15)
    at async SmtpClient.readCmd (https://deno.land/x/denomailer@0.9.0/smtp.ts:329:20)
    at async SmtpClient.#connect (https://deno.land/x/denomailer@0.9.0/smtp.ts:272:21)
    at async SmtpClient.connectTLS (https://deno.land/x/denomailer@0.9.0/smtp.ts:69:5)
    at async file:///home/juan/dev/garn-logger/debug.ts:12:1
mathe42 commented 2 years ago

Are you shure you used the correct port when I use a wrong port I get the same error... Default for SMTP-TLS is 465... You can try the normal connect method. When the server supports StartTLS the connection is automaticly upgraded

I will add an option so you can check if connection is secure (and I make that the default so you can opt out for debuging or in development).

mathe42 commented 2 years ago

added a config option in https://github.com/EC-Nordbund/denomailer/commit/0605d9598dc7f7872a5cf62eaf63c9c6d4eec23b

jupegarnica commented 2 years ago

I think so. my smtp provider gave me it.

I will try with another provider, just in case. I let you know

jupegarnica commented 2 years ago

It worked with another provider.

Thanks