Socket Disconnect while sending simple test message

Giganews Newsgroups
Subject: Socket Disconnect while sending simple test message
Posted by:  PV (no_spam@no_spam.com)
Date: Fri, 11 Nov 2005

Here is my code:
SMTP smtpClient = new SMTP();
smtpClient.Host = this.txtServerName.Text;
smtpClient.Username = this.txtUserName.Text;
smtpClient.Password = this.txtPassword.Text;
Indy.Sockets.Message msg = new Indy.Sockets.Message();
msg.From.Text = this.txtFrom.Text;
msg.Recipients.Add().Text = this.txtTo.Text;
msg.Subject = this.txtSubject.Text;
msg.Body.Text = this.txtMessageBody.Text;
smtpClient.Connect();
try
{
  smtpClient.SendMsg(msg, false);
}
catch (Exception ex)
{
  MessageBox.Show(ex.Message);
}
finally
{
  smtpClient.Disconnect();
}

I get an exception during the disconnect because the server has already
terminated the connection.  I did a packet trace, which looks something like
this:

    Indy Client -  Command: EHLO [my computer name]
    Server - Response: 250-[server name]
    Indy Client - Message: From: [my email address]

But didn't Indy skip a few steps here?  Like:
    Command: MAIL FROM: ...
    Command: RCPT TO: ...
    Command: DATA

Is there something I'm missing in the setup of my Indy.Sockets.SMTP object?

Replies