System.net.mail.SmtpClient send generates a Syntax error, command unrecognized

H

howardr101

Hi,

I've just posted this into the microsoft.public.dotnet.VB group by
mistake - Just reposting it here...

Have hunted around on the groups and can't find anything, hence.

I've tried this against 2 mail servers (mailtraq and hmailserver) and
it occus with both.

The problems seems to be that when the SMTPClient attaches to the
server and the server sends it greeting message, if anything other than
+OK is received by the client it throws an exception and falls over.
Catching the exception is OK, but the client still falls over.

the hmailServer sends :
+OK POP3
the Mailtraq server sends :
+OK <3148.13349250@MyBox> ready for action (Mailtraq
2.8.0.2048/POP3)

and in both cases the SMTPClient blows up in the same way. Is this
class a bit flaky / basic or am I missing something??

During my hunting around on the web people had mentioned creating an
app.exe.config file to capture some logging information, below is the
log I get when I run the app.

System.Net Verbose: 0 : [3680] SmtpClient::.ctor(host=Sage003260,
port=110)
System.Net Information: 0 : [3680] Associating SmtpClient#10549531 with
SmtpTransport#27836922
System.Net Verbose: 0 : [3680] Exiting SmtpClient::.ctor() ->
SmtpClient#10549531
System.Net Verbose: 0 : [3680]
SmtpClient#10549531::Send(MailMessage#49205706)
System.Net Information: 0 : [3680]
SmtpClient#10549531::Send(DeliveryMethod=Network)
System.Net Information: 0 : [3680] Associating SmtpClient#10549531 with
MailMessage#49205706
System.Net Information: 0 : [3680] Associating SmtpTransport#27836922
with SmtpConnection#40198173
System.Net Information: 0 : [3680] Associating SmtpConnection#40198173
with ServicePoint#26239245
System.Net Information: 0 : [3680] Associating SmtpConnection#40198173
with SmtpPooledStream#34826618
System.Net Error: 0 : [3680] Exception in the SmtpClient#10549531::Send
- Syntax error, command unrecognized. The server response was: POP3
System.Net Error: 0 : [3680] at
System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32
port)
at System.Net.Mail.SmtpClient.GetConnection()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
System.Net Verbose: 0 : [3680] Exiting SmtpClient#10549531::Send()

From home (where I don't have the plethora of firewalls like at work) I
tried to connect to an external email server on my website, which is
hosted at 1-and-1 on a unix box. The SMTPClient worked perfectly well
against that server ( don't know what it is - guessing sendmail).


So my question is, has anybody run into the problem of a non-standard
greeting from an SMTP mail server causing their SMTPClient to top
itself? and If so, what's the work around please.

I considered trying to derive a new class from the SMTPClient that
makes it a little for flexible, but I'm not having much joy so far and
timescales are getting tight - as usual.

TIA

Regards
Howard
 
H

howardr101

The solutions were;

1) I'm having a bad day, I was connecting to port 110 - which is POP,
not port 25 which is SMTP. Hence I was pointing the SMTPClient at a POP
service - doh !!!
2) McAfee antivirus is running and it is killing the connection from
the SMTP Client - there's a posting about it blocking / messing with
port 25 in another group. Configured the SMTP Server to listen on port
55, told SMTPClient to connect on port 55... et voila!! it worked

Regards
Howard



Hi,

I've just posted this into the microsoft.public.dotnet.VB group by
mistake - Just reposting it here...

Have hunted around on the groups and can't find anything, hence.

I've tried this against 2 mail servers (mailtraq and hmailserver) and
it occus with both.

The problems seems to be that when the SMTPClient attaches to the
server and the server sends it greeting message, if anything other than
+OK is received by the client it throws an exception and falls over.
Catching the exception is OK, but the client still falls over.

the hmailServer sends :
+OK POP3
the Mailtraq server sends :
+OK <3148.13349250@MyBox> ready for action (Mailtraq
2.8.0.2048/POP3)

and in both cases the SMTPClient blows up in the same way. Is this
class a bit flaky / basic or am I missing something??

During my hunting around on the web people had mentioned creating an
app.exe.config file to capture some logging information, below is the
log I get when I run the app.

System.Net Verbose: 0 : [3680] SmtpClient::.ctor(host=Sage003260,
port=110)
System.Net Information: 0 : [3680] Associating SmtpClient#10549531 with
SmtpTransport#27836922
System.Net Verbose: 0 : [3680] Exiting SmtpClient::.ctor() ->
SmtpClient#10549531
System.Net Verbose: 0 : [3680]
SmtpClient#10549531::Send(MailMessage#49205706)
System.Net Information: 0 : [3680]
SmtpClient#10549531::Send(DeliveryMethod=Network)
System.Net Information: 0 : [3680] Associating SmtpClient#10549531 with
MailMessage#49205706
System.Net Information: 0 : [3680] Associating SmtpTransport#27836922
with SmtpConnection#40198173
System.Net Information: 0 : [3680] Associating SmtpConnection#40198173
with ServicePoint#26239245
System.Net Information: 0 : [3680] Associating SmtpConnection#40198173
with SmtpPooledStream#34826618
System.Net Error: 0 : [3680] Exception in the SmtpClient#10549531::Send
- Syntax error, command unrecognized. The server response was: POP3
System.Net Error: 0 : [3680] at
System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32
port)
at System.Net.Mail.SmtpClient.GetConnection()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
System.Net Verbose: 0 : [3680] Exiting SmtpClient#10549531::Send()

From home (where I don't have the plethora of firewalls like at work) I
tried to connect to an external email server on my website, which is
hosted at 1-and-1 on a unix box. The SMTPClient worked perfectly well
against that server ( don't know what it is - guessing sendmail).


So my question is, has anybody run into the problem of a non-standard
greeting from an SMTP mail server causing their SMTPClient to top
itself? and If so, what's the work around please.

I considered trying to derive a new class from the SMTPClient that
makes it a little for flexible, but I'm not having much joy so far and
timescales are getting tight - as usual.

TIA

Regards
Howard
 

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

Top