The Trunk: SqueakSSL-SMTP-ar.1.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: SqueakSSL-SMTP-ar.1.mcz

commits-2
Tobias Pape uploaded a new version of SqueakSSL-SMTP to project The Trunk:
http://source.squeak.org/trunk/SqueakSSL-SMTP-ar.1.mcz

==================== Summary ====================

Name: SqueakSSL-SMTP-ar.1
Author: ar
Time: 27 November 2011, 11:40:06.998 am
UUID: e091f7d9-2e75-f547-94e7-043537eb417e
Ancestors:

SecureSMTPClient for sending email via SSL.

==================== Snapshot ====================

SystemOrganization addCategory: #'SqueakSSL-SMTP'!

SMTPClient subclass: #SecureSMTPClient
        instanceVariableNames: ''
        classVariableNames: ''
        poolDictionaries: ''
        category: 'SqueakSSL-SMTP'!

----- Method: SecureSMTPClient class>>exampleGMailFrom:to:password: (in category 'example') -----
exampleGMailFrom: gmailAddress to: rcvrAddress password: pw
        "Sends email via secure smtp through GMail"

        | message smtpClient |
        smtpClient := self new.
        smtpClient user: gmailAddress.
        smtpClient password: pw.
        smtpClient openOnHost: (NetNameResolver addressForName: 'smtp.gmail.com') port: 465.

        message := MailMessage empty.
        message setField: 'from' toString: gmailAddress.
        message setField: 'to' toString: rcvrAddress.
        message setField: 'subject' toString: 'Hello World'.
        message body:
                (MIMEDocument contentType: 'text/plain' content: 'bla bla bla').

        smtpClient mailFrom: gmailAddress to: {rcvrAddress} text: message text.
        smtpClient quit.
!

----- Method: SecureSMTPClient>>ensureConnection (in category 'private') -----
ensureConnection
        self isConnected
                ifTrue: [^self].
        self stream
                ifNotNil: [self stream close].

        self stream: (SecureSocketStream openConnectionToHost: self host port: self port timeout: self standardTimeout).
        self stream sslConnect.
        self checkResponse.
        self login!