eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'SMTPClient':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: SMTPClient


Inheritance:

   Object
   |
   +--NVTClient
      |
      +--SMTPClient

Package:
stx:goodies/communication
Category:
Net-Communication-SMTP
Version:
rev: 1.23 date: 2018/01/19 22:29:39
user: cg
file: SMTPClient.st directory: goodies/communication
module: stx stc-classLibrary: communication

Description:


a very simple SMTP mail client.
Right now, there are two entries:
    sendMessageString:
        which expects a string argument, containing all of
        the mail info (from lines, subject etc.)
    
    sendMessage:
        which expects a letter object, which itself is able
        to convert itself to a string. At the time of writing,
        such a letter object does not exist,


Class protocol:

class initialization
o  initialize
self initialize.

signal constants
o  smtpErrorSignal


Instance protocol:

accessing
o  clientHostName

o  clientHostName: something

o  passWord

o  passWord: something

defaults
o  defaultPassword

o  defaultPort
Socket portOfService:'smtp'

o  defaultUser

operations
o  help
send a 'HELP' command to ask about the partners capabilities.
Return a collection of help lines.

o  sendMessage: rfc822Message
send an rfc822Message (Net::MailMessage)

o  sendMessage: rfc822Message to: receiver
send an rfc822Message

o  sendMessage: rfc822Message toAll: receivers
send an rfc822Message

o  sendMessageString: rfc822MessageString to: receiver
send an rfc822MessageString

o  sendMessageString: rfc822MessageString toAll: receivers
send an rfc822MessageString

o  sendMessageString: rfc822MessageString withSubject: aSubjectString contentType: aContentTypString to: receiver
send an rfc822MessageString

o  sendMessageString: rfc822MessageString withSubject: aSubjectString contentType: aContentTypString to: receiver cc: ccReceiver bcc: bccReceiver
send an rfc822MessageString

o  sendMessageString: rfc822MessageString withSubject: aSubjectString contentType: aContentTypString to: receiver fromLabel: fromLabel
send an rfc822MessageString

o  sendMessageString: rfc822MessageString withSubject: aSubjectString contentType: aContentTypeString toAll: receivers
send an rfc822MessageString

o  sendMessageString: rfc822MessageString withSubject: aSubjectString contentType: aContentTypeString toAll: receivers fromLabel: fromLabel
send an rfc822MessageString

o  sendMessageString: rfc822MessageString withSubject: aSubjectString contentType: aContentTypeString toAll: receivers toAllCc: ccReceivers toAllBcc: bccReceivers

o  sendMessageString: rfc822MessageString withSubject: aSubjectString contentType: aContentTypeString toAll: receivers toAllCc: ccReceivers toAllBcc: bccReceivers fromLabel: fromLabel
send an rfc822MessageString

o  sendMessageString: rfc822MessageString withSubject: aSubjectString to: receiver
send an rfc822MessageString

o  sendMessageString: rfc822MessageString withSubject: aSubjectString to: receiver cc: ccReceiver bcc: bccReceiver
send an rfc822MessageString

o  sendMessageString: rfc822MessageString withSubject: aSubjectString toAll: receivers
|snmp|

snmp := SMTPClient new.
snmp connectTo:'exept'.
snmp userName:'penk@exept.de'.
snmp sendMessageString:('this is a test message\.\last line' withCRs) withSubject:'Message from SmalltalkX' to:'penk@exept.de'.
snmp close

o  verifyUser: userName
|snmp|

snmp := SMTPClient new.
snmp connectTo:'exept'.
Transcript showCR:(snmp verifyUser:'fooUser').
snmp close

private - commands & responses
o  handleReplyCode: lastReplyCode
Raise an error if the last response from the SMTP server has an error.

o  sendGoodByeCommand

private - connection setup
o  getInitialConnectResponse

o  performLoginSequence
invoked after the socket connection has been setup


Examples:


    SMTPClient new
        userName:'sr';
        connectTo:(IPSocketAddress localHost);
        sendMessageString:'this is a test message\.\last line' withCRs 
                to:'stefan.reise@gmx.de';
        close.
    SMTPClient new
        userName:'cg';
        connectTo:(IPSocketAddress hostName:'exeptn');
        sendMessageString:'This is a test message\.\last line' withCRs 
            withSubject:'testmail' 
            to:'sr@exeptn';
        close.
    |m|

    m := Net::MailMessage new.
    m 
        from:'stefan.reise@exept.de';
        to:'stefan.reise@gmx.de';
        subject:'Test von stx';
        contents:'Dies ist ein mailtext';
        yourself.

    SMTPClient new
        userName:'stefan.reise';
        password:'rappel72';
        connectTo:(IPSocketAddress hostName:'mail.exept.de');
        sendMessage:m;
        close.


ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Wed, 24 Apr 2024 10:40:57 GMT