Project

General

Profile

Actions

Improvements #12664

closed
DM RM

Wt::Mail::Client::send always fails after trying to send to an invalid email address

Improvements #12664: Wt::Mail::Client::send always fails after trying to send to an invalid email address

Added by Dries Mys over 2 years ago. Updated 3 months ago.

Status:
Closed
Priority:
Normal
Target version:
Start date:
05/07/2024
Due date:
% Done:

0%

Estimated time:

Description

Trying to send to an invalid email address may result in receiving a SMTP 501 response. Wt spawns the following error message:

Mail.Client: Unexpected response 501

failIfReplyCodeNot also throws an exception, which is catched by the send function, but this function closes the socket when catching an exception. As a consequence, all subsequent send messages fail with the following error:

Mail.Client: Can't send message: not connected

Is it necessary to close the connection when a unexpected response is received?
Or can we automatically reconnect?
Or can we expose the connection status (e.g. add a Wt::Client::isConnected method), in order the caller can at least determine whether is should reconnect?
Or should the caller always assumes the connection is disconnected when sending fails? If so, shouldn't this be documented?

MV Updated by Matthias Van Ceulebroeck 11 months ago Actions #1

  • Tracker changed from Bug to Improvements
  • Target version set to 4.13.2

Hey Dries,

I think the socket is always closed, to ensure that we wouldn't reach a bad state. If the connection/socket is somehow messed up, one could get a variety of AsioWrapper::error_codes. To avoid this, and handling these cases, the client handles the socket "defensively", closing it on any error.

I agree though, then that developers should be able to query the state. So adding a bool Wt::Mail::Client::isConnected() seems like a good idea.

I think often I see people just creating a client in a local scope, using it and then discarding it. So it essentially is often used as a "use-once" class.

RM Updated by Romain Mardulyn 9 months ago Actions #3

  • Status changed from New to InProgress
  • Assignee set to Romain Mardulyn

RM Updated by Romain Mardulyn 9 months ago Actions #4

  • Status changed from InProgress to Review
  • Assignee deleted (Romain Mardulyn)

RM Updated by Romain Mardulyn 5 months ago Actions #5

  • Target version changed from 4.13.2 to 4.13.3

MV Updated by Matthias Van Ceulebroeck 4 months ago Actions #6

  • Assignee set to Matthias Van Ceulebroeck

RM Updated by Romain Mardulyn 4 months ago Actions #7

  • Status changed from Review to Implemented @Emweb
  • Assignee changed from Matthias Van Ceulebroeck to Romain Mardulyn

RM Updated by Romain Mardulyn 3 months ago Actions #8

  • Status changed from Implemented @Emweb to Closed
Actions

Also available in: PDF Atom