gen-smtp / gen_smtp

The extensible Erlang SMTP client and server library.
Other
684 stars 266 forks source link

Send error receiving e-mail from Hikvision DVR #259

Open igormq opened 3 years ago

igormq commented 3 years ago

Hello, I am using the gen_smtp to receive e-mail messages from Hikvision DVR and it's returning {:send_error, :closed} messages, but before this, I am receiving some weird other commands, see the image below

image

I have activated older versions of tls, but I don't know what I am doing wrong. I am using the tcp procotol, and STARTTLS.

Could you guys help me?

bamorim commented 3 years ago

I think I figured out the problem here.

gen_smtp_server_session sends 221 Bye whenever it receives a QUIT (code here), the problem is that most clients (gen_smtp_client included) close the TCP socket as soon as they send the QUIT message (gen_smtp_client exampe) and with that, there is a chance that the socket will be already closed and since any error on Transport:send will make the session throw, it generates this error.

My suggestion would be to set the state to have something that informs that we are "quitting" so send doesn't throw in case of a Transport:send error.

If you think this makes sense, I can try to write a PR that does that.

bamorim commented 3 years ago

I think it is the same as #239