[squeak-dev] SMTPClient with bad command sequence

Torsten Bergmann astares at gmx.de
Thu Mar 27 22:45:24 UTC 2008


I want to send a mail using an authenticated SMTP server.
But Squeak does not deliver the mail after evaluating the 
following code:

|ip client message|
ip := NetNameResolver addressForName: 'smtp.yourprovider.com'.
client := SMTPClient new.
client user: 'itsme'.
client password: 'mypassword'.
client openOnHost: ip port: 25.
message := 'From: "noreply at sender.com"
To: abc at def.com
Subject: Test

Just a test'.
[client mailFrom: 'noreply at sender.com' to: {'abc at def.com'}  text: message.
	 client quit] ensure: [client close]

The SMTP server sends back an "503 Bad sequence of commands" error.
After digging into the protocol I found out the correct order 
(HELO was missing) and patched the system by adding the following 
method to SMTPClient 

	self isConnected
		ifTrue: [^self].
	self stream
		ifNotNil: [self stream close].

	self stream: (SocketStream openConnectionToHost: self host port: self port).
	self checkResponse.
	self initiateSession.
	self login

Only the line with "self initiateSession" is new compared to the superclass method in ProtocolClient. But it is awfull to copy down
most parts of the superclass method.

Who is taking care of the Network-Protocols package so we can
apply a better (refactored) solution?


Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger

More information about the Squeak-dev mailing list