Re: Socket Disconnect while sending simple test message

Giganews Newsgroups
Subject: Re: Socket Disconnect while sending simple test message
Posted by:  Robert Deck (r…@deck.com)
Date: Sat, 12 Nov 2005

Use "smtpClient.Send(msg);" and everything will work fine.

> 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

In response to

Socket Disconnect while sending simple test message posted by PV on Fri, 11 Nov 2005