help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] IMAP and SMTP - documentation


From: Paolo Bonzini
Subject: Re: [Help-smalltalk] IMAP and SMTP - documentation
Date: Tue, 28 Aug 2007 16:30:35 +0200
User-agent: Thunderbird 2.0.0.6 (Macintosh/20070728)

Stephen wrote:
I've got another question...

I see there are SMTP, POP and IMAP libraries there. I haven't found any sample code in the source or after extensive googling. If someone could point me in the right direction for the docs that would be really appreciated. (I'm assuming that the code has been adapted from another smalltalk for which there is documentation.)

Unfortunately, there are no docs. The code was adapted from public domain or (for IMAP) LGPL implementation.

However, SMTP and POP are relatively easy to figure out from the examples. For example, for SMTP there is this:

exampleHost: host
    "NetClients.SMTP.SMTPClient exampleHost: 'localhost'."

    | user message client |
    user := 'address@hidden' bindWithArguments: { Smalltalk getenv: 'USER'.
       IPAddress localHostName }.

    message := MIME.MimeEntity readFrom:
('From: ', user, '
To: ', user, '
To: foo', user, '
Bcc: ', user, '
Subject: Test mail from Smalltalk (SMTPClient)

This is a test mail from Smalltalk (SMTPClient).
') readStream.

    client := SMTPClient connectToHost: host.
    [client sendMessage: message]
        ensure: [client close].!

It connects to the given host, port 25, and sends a small message. Likewise, this is for POP:

exampleHost: host username: username password: password
    "NetClients.POP.POPClient exampleHost: ... etc."
    | client |
    client := self connectToHost: host.
    [client
        username: username
        password: password.

        client login.
Transcript showCr: 'New messages: ', client newMessagesCount printString.
        Transcript showCr: 'bytes ', client newMessagesSize printString.
        Transcript showCr: 'ids ', client newMessagesIds printString.
        Transcript showCr: 'sizes ', client newMessages printString.

        client
            getNewMailMessages: [:m | m inspect]
            delete: false
    ] ensure: [client close] ! !


If you'd like to contribute back documentation patches as part of your experimentation, you're really welcome!

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]