EC-Nordbund / denomailer

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

issue getting denomailer running #40

Closed mathe42 closed 1 year ago

mathe42 commented 1 year ago

@Enyorose Your code looks good (also the debug-output). Could you try it again with the debug.encodeLB option set to true?

mathe42 commented 1 year ago

Just for your information it looks like a bug / issue with your specific smtp-server.

Enyorose commented 1 year ago

Hello here is the document requested, we are using an individually owned company mailer that we host on site. I read that we are unable to use the Microsoft servers and the google servers so we moved it to a different one. Would you have any idea what it may be specifically blocking so I can get my IT guys to look for it? debug with true.txt

mathe42 commented 1 year ago

Just some quick info:

  1. I can see the send functions runs until here https://github.com/EC-Nordbund/denomailer/blob/main/client/basic/client.ts#L321
  2. The server doesn't have reacted to sending ".\r\n".

Some ideas to test (just use deno vendor so you can modify the code)

at https://github.com/EC-Nordbund/denomailer/blob/main/client/basic/client.ts#L316 try adding await this.#connection.writeCmd("\r\n");.

If you can send me some server-credentials so I can test directly on your smtp-server it will be faster fixed. (email: 2pi_r2@gmx.de)

Enyorose commented 1 year ago

So I did as you requested and added that piece into the spot you suggested, I have also attached the .debug document.

I'm talking with my smtp server tech, what kinds of settings would you look for to fix this issue?

Enyorose commented 1 year ago

I have theory, I have been researching with my tech guy and it looks its recieving the message and waiting for a '.' at the end to be able to send it. I found a document on the smtp command https://www.shellhacks.com/send-email-smtp-server-command-line/ and it mentions their needs to be a period on a line by its self to signify the end. Both the server and I are getting that request, I'm sure you've built that in somewhere I'm just not sure why its not running.

mathe42 commented 1 year ago

I'm sure you've built that in somewhere I'm just not sure why its not running.

I can see that denomailer sends this message:

(1) ['.
']

at end of your log.

So we are here https://github.com/EC-Nordbund/denomailer/blob/main/client/basic/client.ts#L315

from there on the following happens:

  try { // started in L75
   await this.#connection.writeCmd(".\r\n"); // send . to server to end data mode (the server did not end data mode)

   this.#connection.assertCode( // the server is in "DATA-MODE" so it sends nothing so this will throw
        await this.#connection.readCmd(),
        CommandCode.OK,
      );
      await this.#cleanup();
      this.#que.next();
    } catch (ex) {
      await this.#cleanup(); // as server is still in "DATA-MODE" this is an infinite loop.
      this.#que.next();
      throw ex;
    }
  }
mathe42 commented 1 year ago

Try import denomailer from https://raw.githubusercontent.com/EC-Nordbund/denomailer/fix/data-mode/mod.ts this should give an error and logs "Error while in datamode - connection not revoverable"

Enyorose commented 1 year ago

So I ran that test mod, and it provided the error code. Is there any ideas on how to make it work?

mathe42 commented 1 year ago

I'm not sure I would guess that this is an error with the SMTP server. I don't know what other clients are doning differently.

I just had a lock at nodemailer (for nodejs) and it basicly does the same (refrence: https://github.com/nodemailer/nodemailer/blob/master/lib/smtp-connection/data-stream.js#L93)

What you can do is try changing this line https://github.com/EC-Nordbund/denomailer/blob/main/client/basic/client.ts#L315 and experiment with different strings. But I'm quite sure that this will not change anything.

mathe42 commented 1 year ago

No more reproduction provided so closing this.