how I do telnet

  • Thread starter Alhambra Eidos Desarrollo
  • Start date
A

Alhambra Eidos Desarrollo

hi all

how can i do using c#

telnet mail.domain.es 25

using c# code

Iwant know if i can access to telnet (smtp 25) of a domain.

thanks.
 
A

anonymous

yes and no.

You have built in classes for SMTP so you shouldnt have to "telnet". If you
really must telnet then yes you have full access to sockets to do that also.
I dont think you have a base .net telnet class already rolled though.


"Alhambra Eidos Desarrollo"
 
A

anonymous

FYI you didnt mention what version but im on 2.0 and have
System.Net.Mail.SmtpClient available.


"Alhambra Eidos Desarrollo"
 
A

Arne Vajhøj

Alhambra said:
how can i do using c#

telnet mail.domain.es 25

using c# code

Iwant know if i can access to telnet (smtp 25) of a domain.

TcpClient class should do fine.

Example:

public static bool TestMailServer(string server)
{
try
{
string ownhost = Dns.GetHostName();
TcpClient client = new TcpClient(server, 25);
StreamWriter wrt = new StreamWriter(client.GetStream());
wrt.WriteLine("HELO " + ownhost);
wrt.WriteLine("QUIT");
wrt.Flush();
wrt.Close();
client.Close();
return true;
}
catch
{
return false;
}
}

Arne
 
A

Arne Vajhøj

anonymous said:
You have built in classes for SMTP so you shouldnt have to "telnet".

The email classes can only be used to actually send an email not
to just test if the SMTP server are there.

That may or may not be important.
If you
really must telnet then yes you have full access to sockets to do that also.
I dont think you have a base .net telnet class already rolled though.

..NET does not come with telnet, but telnet is not needed for talking
to a SMTP server. Basic socket is enough - and .NET has that - TcpClient
is most likely the easiest interface.

Arne
 
A

anonymous

Very crude example but you felt the need to elebrate on my response with
garbage so here is one way to "test if the SMTP server are there" using the
SmtpClient.

static void Main(string[] args)
{
System.Net.Mail.SmtpClient smtpclient = new
System.Net.Mail.SmtpClient("192.168.0.250", 25);
try
{
smtpclient.Send("root@localhost", "root@localhost",
"subject", "body");
}
catch (Exception ex)
{
Console.WriteLine("Failure Sending\n" +
ex.InnerException.Message.ToString());
Console.Read();
return;
}

Console.WriteLine("Success");
Console.Read();

}
 
A

Arne Vajhøj

anonymous said:
Very crude example but you felt the need to elebrate on my response with
garbage

Not garbage - pure truth.
so here is one way to "test if the SMTP server are there" using the
SmtpClient.

[code omitted]

That code actually sends an email.

Arne
 
X

Xpresslearn

Here is an example of a telnet library along with a program that uses it to log into a Cisco router and download the IOS configuration.

http://www.xpresslearn.com/networking/code/csharp-telnet-client



AlhambraEidosDesarroll wrote:

how I do telnet
13-Jan-09

hi al

how can i do using c

telnet mail.domain.es 2

using c# cod

Iwant know if i can access to telnet (smtp 25) of a domain

thanks.

Previous Posts In This Thread:

how I do telnet
hi al

how can i do using c

telnet mail.domain.es 2

using c# cod

Iwant know if i can access to telnet (smtp 25) of a domain

thanks.

yes and no.You have built in classes for SMTP so you shouldnt have to "telnet".
yes and no

You have built in classes for SMTP so you shouldnt have to "telnet". If you
really must telnet then yes you have full access to sockets to do that also.
I dont think you have a base .net telnet class already rolled though

"Alhambra Eidos Desarrollo"

FYI you didnt mention what version but im on 2.0 and have System.Net.Mail.
FYI you didnt mention what version but im on 2.0 and hav
System.Net.Mail.SmtpClient available

"Alhambra Eidos Desarrollo"

Re: how I do telnet
Alhambra Eidos Desarrollo wrote

TcpClient class should do fine

Example

public static bool TestMailServer(string server

tr

string ownhost = Dns.GetHostName()
TcpClient client = new TcpClient(server, 25)
StreamWriter wrt = new StreamWriter(client.GetStream())
wrt.WriteLine("HELO " + ownhost)
wrt.WriteLine("QUIT")
wrt.Flush()
wrt.Close()
client.Close()
return true

catc

return false



Arne

Re: how I do telnet
anonymous wrote

The email classes can only be used to actually send an email no
to just test if the SMTP server are there

That may or may not be important

..NET does not come with telnet, but telnet is not needed for talkin
to a SMTP server. Basic socket is enough - and .NET has that - TcpClien
is most likely the easiest interface

Arne

Very crude example but you felt the need to elebrate on my response with
Very crude example but you felt the need to elebrate on my response with
garbage so here is one way to "test if the SMTP server are there" using the
SmtpClient

static void Main(string[] args

System.Net.Mail.SmtpClient smtpclient = new
System.Net.Mail.SmtpClient("192.168.0.250", 25)
tr

smtpclient.Send("root@localhost", "root@localhost",
"subject", "body")

catch (Exception ex

Console.WriteLine("Failure Sending\n" +
ex.InnerException.Message.ToString())
Console.Read()
return


Console.WriteLine("Success")
Console.Read()




Re: how I do telnet
anonymous wrote

Not garbage - pure truth

[code omitted

That code actually sends an email

Arne


Submitted via EggHeadCafe - Software Developer Portal of Choice
MSChart For VB.Net
http://www.eggheadcafe.com/tutorial...4dc6-9aa7-4f6246763650/mschart-for-vbnet.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

TELNET software, how to? 7
Parsing Telnet Commands? 5
C# Telnet Server 3
Telnet Clear Screen? 9
Star Wars via Telnet. 1
VBA code for for telnet 1
Socket Error. Help 2
Another ASCII Formatting Question 22

Top