- priority: 5 --> 6
- assigned_to: nobody --> sheda0
Because of the current implementation of the sending
sequence, there are cases when, AFTER receiving
confirmation of the server that the email data has been
successfully received and BEFORE sending the final
"QUIT" command, the connection can be broken and
OpenSMTP throws an exception.
However, as defined in RFC 821, as soon as the
confirmation has been received, the message must be
considered has sent and consequently, OpenSMTP MUST NOT
throw any exception after this point. Otherwise, the
calling program may think that the message has not been
send and try to send it again. This may result in
emails be sent twice!
I've done some tests with several email clients and my
SMTP server and only OpenSMTP reports an error when
disconnection occurs at this point.
The right implementation (in pseudo-code) is:
---------------
/// Format the message
/// Open the connection
try {
/// Do your whole stuff here
/// The last instruction is receiving the data
/// transfer confirmation from the server
}
finally
{
try
{
Send ( "QUIT" );
myStream.Flush();
}
catch {} // Don't report any error at this point
mySocket.Close();
myStream.Close();
}
---------------