[ENH] SMTPClientSenderBracket-nk ([er][et][sm][sl] Looks good; test attached)

Frank Shearar frank.shearar at rnid.org.uk
Tue Mar 23 10:45:50 UTC 2004


> >>> "Lex Spoon" 03/22/04 19:13 >>>

> It would seem even better to use the existing MailAddressParser, which
> does full parsing of Internet email addresses.  Here's an
> example usage
> from MailMessage:
>
>
> 	recipients
> 		^ (Set withAll: (MailAddressParser addressesIn:
> self to))
> 			addAll: (MailAddressParser addressesIn:
> self cc);
> 			yourself
>
> I do not have a good feel for how much parsing SMTPClient should be
> doing, but if it is going to do parsing, it seems you may as well use
> the full parser.  FWIW, writing a full mail-address parser is
> surprisingly difficult....  you wouldn't want to start with something
> "simple" and then fix case after case.

Well, if MailAddressParser does the job of parsing emails pretty
well/thoroughly
(I've not checked) then we might as well solve the problem completely with
something like

mailFrom: aString
	"MAIL <SP> FROM: <reverse-path> <CRLF>"
	| addresses |
	addresses := MailAddressParser addressesIn: aString.
	self sendCommand: 'MAIL FROM: <', addresses first, '>.
	self checkResponse.

That should do the trick, shouldn't it? And that keeps email address parsing
in one place.

One thing that the implementation above does that differs from Ned's is that
if
you pass in 'Frank <frank at angband.za.org>' you'll lose the 'Frank ' part. I
don't know if that's such a nice thing. As MailAddressParser's class comment
says, "It would be nice to also get a list ('Joe <joe at foo>'  '<jane>')." So
maybe
we should use my code snippet above, and make MailAddressParser Do The Right
Thing?

frank





More information about the Squeak-dev mailing list